Documentation | Project Roadmap | NuGet

Project Description

ConsoleFx is a .NET library to build command-line applications with support for command-line argument parsing/handling, including error handling and validations

Using the ConsoleFx command-line parser, you can specify a whole host of conditions for specifying command-line arguments. These can include the ability to:
  • Enforce the order of the command-line arguments
  • Specify switch options and limit the number of times they can occur as command-line arguments
  • Allow parameters to be specified for switch options, and limit the number of parameters that can be specified
  • Specify non-switch arguments and how they are to be used
  • Run custom validations on switch parameters and non-switch arguments, including tests for regular expressions, file masks, integers, booleans, enums, etc.
  • Automatically map non-switch arguments to strong-typed properties for easier readability

In addition, ConsoleFx also provides the following extras:
  • A separate command-line parsing engine that can be used in non-CLI applications like Windows Forms and WPF applications.
  • Ability to create an interactive command-line shell application that utilizes ConsoleFx's build-in parser to handle input.
  • Utility classes for console output capturing and extensions to the Console class. We plan to add other utility classes in the future, making it the all-in-one solution for creating your command-line applications.

We have a large documentation section with Getting Started guides, advanced topics and references for ConsoleFx. In particular, check out our Getting Started guide to writing a simple console application to get a quick start on using ConsoleFx.

Overview

ConsoleFx provides a fluent API for specifying the rules for processing command-line arguments.

For example, the following code creates a command-line application that supports these signatures:
BACKUP [/type:Full|Incremental] [/verbose] <directory to backup>
BACKUP /?

var backupApp = new ConsoleProgram(includeHelpSupport: true);
backupApp.AddOption("type", "t", expectedParameters: 1)
    .ValidateWith(new EnumValidator(typeof(BackupTypes))))
    .AssignTo(() => BackupType);
backupApp.AddOption("verbose", "v")
    .Flag(() => VerboseOutput);
backupApp.AddArgument()
    .ValidateWith(new PathValidator { PathType = PathType.Directory, CheckIfExists = true })
    .AssignTo(() => DirectoryToBackup);
backupApp.Run();

NuGet Support

The ConsoleFx binaries and code are now available through NuGet. See the ConsoleFx assemblies and deployment scenarios section for scenarios on using the code packages.

Last edited Mar 22 at 11:01 AM by jeevanjj, version 50