Command line interface

Major players like Microsoft and Google are shipping CLIs (command line interface) with their products. Now you can perform tasks like scaffolding a TypeScript class or packaging your project for deployment right from the command prompt. There are some folks who hear about CLIs and roll their eyes — “we had that in the 90s and now it’s back” they say — “what’s the point?”. Yes, the industry moves in circles, but I see this proliferation of CLIs as a positive development and hope it sticks for years to come. As a developer, I’d much rather have a command line interface as a way into my solution than anything else.

So, for the past few projects, I included a CLI as an auxiliary executable, and in general, it was well received by my clients. Actions like scaffolding, seeding the database, or running integration tests have been made available to DevOps via the command line interface.

Included here is a link to a small .NET Core console app that provides the skeleton for the CLI functionality I use in my projects. There are several services that worth a mention here

 

  • The help service provides a way to discover what commands are available and then to get more information about a particular command.
  • The configuration service aggregates arguments from the config files and user input
  • The notification service catches unhandled exceptions and emails them to an admin. This may be useful if you want to run this CLI on a schedule and want to get notified if the scheduled run has failed.