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.
GreetCommand is an example of a command, see Commands/GreetCommand.cs.
- Create a new class for your command, eg.
Commands.ListCommand - Register the command in the
RootCommandlike this:
app.Command("list", c => ListCommand.Configure(c, options));- Profit!
IsEnthousiastic is an example of a global option.
- Add the property to
CommandLineOptions - Add a call to
app.Optionorapp.ArgumentinCommandLineOptions.Parseand store the result - Store the property in
optionsat the bottom ofCommandLineOptions.Parse