FluentConsoleApplication 0.2.0

This library for .NET uses a fluent interface of chained methods for building complete Command-Line Applications.

Install-Package FluentConsoleApplication -Version 0.2.0
dotnet add package FluentConsoleApplication --version 0.2.0
<PackageReference Include="FluentConsoleApplication" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FluentConsoleApplication --version 0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Software Developers often reinvent command-line interfaces for their tools, which
is very easy until the application's interface becomes too complex to be modified effectively.
This tool is an elegant and quick way to do this and let developers focus of higher tasks.

An application can be used in many ways:

  • Directly from the code, as in the following usage example
  • Called with arguments provided from the console
  • In a Read-Evaluate-Parse Loop (REPL)

Usage example

Defining an application, with all its commands.

var application = FluentConsoleApplication
  .Create("Calculator",  "Application to calculate.")
    .DefineCommand("add", "Add two numbers")
      .WithParameter<int>("X", "First operand")
      .WithParameter<int>("Y", "Second operand")
        .Does(args => Console.WriteLine("Total is " + (args.X + args.Y)))
    .DefineCommand("mult", "Multiply two numbers")
      .WithParameter<double>("X", "First operand")
      .WithParameter<double>("Y", "Second operand")
        .Does(args => Console.WriteLine("Total is " + (args.X * args.Y)));
    .DefineCommand("help")
        .Does(args => Console.WriteLine(args.Application.GetDocumentation()));

Using the application by invoking a command with its required arguments, if any:

application.Run("add 5 2");

Output:

Total is 7

Automatic documentation can also be generated for an Application. This documentation is
based on the names, types and descriptions provided when the application was defined.

In this example, the help command generates documentation for the currently running
application.

Output:

Calculator: Application to calculate.
 - add [X] [Y] - Add two numbers
 - mult [X] [Y] - Multiply two numbers
 - help

Software Developers often reinvent command-line interfaces for their tools, which
is very easy until the application's interface becomes too complex to be modified effectively.
This tool is an elegant and quick way to do this and let developers focus of higher tasks.

An application can be used in many ways:

  • Directly from the code, as in the following usage example
  • Called with arguments provided from the console
  • In a Read-Evaluate-Parse Loop (REPL)

Usage example

Defining an application, with all its commands.

var application = FluentConsoleApplication
  .Create("Calculator",  "Application to calculate.")
    .DefineCommand("add", "Add two numbers")
      .WithParameter<int>("X", "First operand")
      .WithParameter<int>("Y", "Second operand")
        .Does(args => Console.WriteLine("Total is " + (args.X + args.Y)))
    .DefineCommand("mult", "Multiply two numbers")
      .WithParameter<double>("X", "First operand")
      .WithParameter<double>("Y", "Second operand")
        .Does(args => Console.WriteLine("Total is " + (args.X * args.Y)));
    .DefineCommand("help")
        .Does(args => Console.WriteLine(args.Application.GetDocumentation()));

Using the application by invoking a command with its required arguments, if any:

application.Run("add 5 2");

Output:

Total is 7

Automatic documentation can also be generated for an Application. This documentation is
based on the names, types and descriptions provided when the application was defined.

In this example, the help command generates documentation for the currently running
application.

Output:

Calculator: Application to calculate.
 - add [X] [Y] - Add two numbers
 - mult [X] [Y] - Multiply two numbers
 - help

Release Notes


    - Generate user documentation for the Application
    - Generate user documentation for `DefinedCommand` and `DefinedParameter`
    - Add automatic dynamic field as argument, called `Application`,
      with a pointer to the current Application being run.
   

  • .NETFramework 4.5

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.2.0 278 3/11/2018