Skip to content
Mogens Heller Grabe edited this page Feb 28, 2016 · 2 revisions

This is GoCommando, a simple .NET console application library.

It is meant to ease the burden when you want to build console applications that accept commands, where the acceptable set of parameters vary depending on the chosen commands.

A good and popular example of this style of console application is the NuGet command line, which is generally invoked with this pattern:

nuget <command>

where <command> can be lots of things, and then - depending on which command you have chosen - you will be able to supply additional arguments to that command, like e.g.

nuget pack *.nuspec -OutputDirectory C:\Temp 

Getting started quickly

  1. Create a new "Console Application"
  2. Install-Package GoCommand -ProjectName <your-console-application>
  3. In your Main method: Go.Run(); (that's it!)

If you run the application now, it will fail with a message saying that there has to be at least one command available. You can now add commands to the program by doing this:

  1. Add a new class
  2. Decorate that class with the CommandAttribute, e.g. like so: [Command("whatever")]
  3. Make that class implement ICommand

If your command needs additional arguments, you add them as properties to the class with the [Parameter(..)] attribute on them.

That's it 👍 😁

Clone this wiki locally