Not the last console application. LBi.Cli.Arguments

 
event

Today we will look at LBi.Cli.Arguments.
With its (still) beta NuGet package.

Work in progress?

LBi.Cli.Arguments presents itself as something to mimic the syntax and capabilities of PowerShell. Those are big words, but not necessarily false. It tries, but it falls waaaay short.
To begin with, its package is still pre-release despite the last commit being 3 years old. Then we have the pretty lacking (feeling magnanimous today) documentation.

The framework relies on decorating classes with attributes but it comes ready for multi-language support. I also like that the framework makes use of existing attributes from System.ComponentModel.* instead of creating new ones for the same purpose.
And that is about the nicest thing I can say about the framework. That and the fact that exposes a parsing object model in case one feel like getting fancy.

Implementing our example

Implementing our example was not difficult despite the lack of documentation:

Dispatching involves creating a base class or interface that our argument objects implement (in our case IRunnable) in order to get a hand from polymorphism when executing our code.

One can guess from my tone that I am not liking it already. If a concept (a command-like interface) is basic for the sunny-day scenario of a framework to work, I would expect that concept to be baked-in into the framework.

The Challenges

Mandatory Arguments

Mandatory arguments are not the default, but decorating a property with [Required] does the trick:

Extra, undefined arguments will make an error appear.

Non-Textual arguments

Declaring the right type for the property works most of the time.

Default values are provided as strings.

Boolean properties are to be defined as Switch instead on bool for some reason that I fail to comprehend.

Multi-arguments

Collection arguments are supposed to work by using PowerShell's array syntax when passing the value, but I was not able to make it work and, honestly, I gave up trying pretty soon.

Showing Help

Running the program with the -Help argument provides a useful overview of the commands and simple examples.

I could not find a way of focusing the help to a single command without getting the complete (very complete) help.
It uses the "PS way" of getting help via -Detailed, -Examples, -Full which leads me that we can create very complex and useful help, but that I did not try.

Command Dispatching

As mentioned previously, commands are executed (in its simplest form) by providing a base class/interface and calling a method if that interface.
There is nothing in the anemic help that tells us how to tap into the process of creating the command so that dependencies can be injected via IOC container.

Conclusion

LBi.Cli.Arguments left me totally cold. From the pre-release package, to its missing help the best thing I can say is that it was not difficult to have my example working almost completely (save the multi-arguments).

I am certainly not going to push this framework on anyone wanting to create console applications in .NET. And that should be totally OK.

Last Console Series

  1. The beginning
  2. GoCommando
  3. CommandLineParser
  4. PowerArgs
  5. LBi.Cli.Arguments (this)
  6. Command Line Utils
  7. CLAP
  8. Wrap-up