https://github.com/iamarcel/dotnet-core-neat-console-starter
Starter kit for neatly structured neat .NET Core Console / Command Line Apps
https://github.com/iamarcel/dotnet-core-neat-console-starter
command-line csharp dotnet-core
Last synced: 5 months ago
JSON representation
Starter kit for neatly structured neat .NET Core Console / Command Line Apps
- Host: GitHub
- URL: https://github.com/iamarcel/dotnet-core-neat-console-starter
- Owner: iamarcel
- Created: 2016-09-07T07:24:44.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-06-19T10:38:21.000Z (about 9 years ago)
- Last Synced: 2025-06-18T02:39:48.269Z (about 1 year ago)
- Topics: command-line, csharp, dotnet-core
- Language: C#
- Size: 6.84 KB
- Stars: 35
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# .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][1], 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:
```cs
app.Command("list", c => ListCommand.Configure(c, options));
```
3. 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
- Article: [Creating Neat .NET Core Console Apps][2]
- Article: [Structuring Neat .NET Core Console Apps Neatly][3]
[1]: http://www.4dvision.be
[2]: https://gist.github.com/iamarcel/8047384bfbe9941e52817cf14a79dc34
[3]: https://gist.github.com/iamarcel/9bdc3f40d95c13f80d259b7eb2bbcabb