dotnet-core-neat-console-starter icon indicating copy to clipboard operation
dotnet-core-neat-console-starter copied to clipboard

Starter kit for neatly structured neat .NET Core Console / Command Line Apps

.NET Core Neat Console Starter

This is a starting point for creating neatly structured .NET Core console apps in C#, using the Microsoft.Extensions.CommandLineUtils package to parse the commands.

I created this working as a student with 4DVision, who create custom software for complex processes of companies and organizations.

Adding a command

GreetCommand is an example of a command, see Commands/GreetCommand.cs.

  1. Create a new class for your command, eg. Commands.ListCommand
  2. Register the command in the RootCommand like this:
app.Command("list", c => ListCommand.Configure(c, options));
  1. Profit!

Adding a global option

IsEnthousiastic is an example of a global option.

  1. Add the property to CommandLineOptions
  2. Add a call to app.Option or app.Argument in CommandLineOptions.Parse and store the result
  3. Store the property in options at the bottom of CommandLineOptions.Parse

Learn more