My last console application. ManyConsole


Despite having found a sensible framework for console applications (NConsoler) I was kind of put back by their drawbacks, most of them derived by the fact that attributes are used to decorate methods and arguments.

ManyConsole can be easily obtained as a Nuget package to be up and running in no time.

The description of the project reads:

An extension to NDesk.Options for writing console applications with multiple commands

As NDesk.Options and Mono.Options are two sides of the same coin, we can see that the main downside I found in Mono.Options (the lack of the concept of “command”) has been addressed.

ManyConsole thus, moves away from attribute decoration to a mixed model of subclasses with helper methods that aim to facilitate the DSL of Mono.Options. Out sample can be written as two classes (one for each command):

Our commands must override .Run() and declare their arguments/delegates-to-execute pairs in their constructors in a pretty sensible way.
Dispatching commands is simple…

…which translates roughly by:

  1. provide me a collection of commands (that can be auto-magically discovered ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)))
  2. provide the command-line arguments
  3. tell where to write messages

The Challenges

Mandatory Arguments

Mandatory arguments are specified calling the .HasRequiredOption() method and works (as opposed to my experience with Mono.Options) flawlessly by aborting the execution and displaying help:

Non-Textual Arguments

They are defined by using a generic overload of the .HasOption<>() method family. When the conversion is not possible, a descriptive messages telling the details:

As a side note, I was able to convert the argument to Nullable<int>, which Mono.Options was unable to.


Inheriting the delegate philosophy, defining multi-arguments is nothing special, but the delegate will be executed multiple times, so adding the values to a list is easy enough.

Showing Help

Running the program without arguments shows a very descriptive list of available commands:

And detailed help for each of the commands can also be displayed:

Note the name of the command “something-else”. By moving away from attributes we can easily choose our names freely and localize the messages at will.

Command Dispatching

As we read from the project description, the project comes to “solve” the lack of commands of Mono.Options.
And it does a great job.


ManyConsole would be my choice if I was to create a console application in .NET. Powerful (we did not even mention the ability to interpret interactive commands –Console-mode commands–), easy and developer-friendly.

But, alas, the title of the series states the my last console program has already been written. What would I use then, if not a console program?

Wait a bit longer.


Last Console Series

  1. The Beginning
  2. Mono.Options
  3. NConsoler
  4. ManyConsole (this)
  5. Powershell