Skip to content

Features#

Commands#

  • Define commands as methods and/or classes (docs)

    • supports the pattern you prefer:
      • class per command
      • logically grouped commands as methods

        similar to ASP.NET endpoints

  • Parameter Resolvers (docs)

    Inject console and other services as parameter to the command methods: IConsole, CommandContext, CancellationToken & IPrompter by default.

  • Infinite nesting of subcommands (docs)

    • Nested classes
    • Composed classes

      reuse subcommands in multiple parents

    • Commands define arguments for their subcommands
  • Command Interception

    • via interceptor methods (aka hooks) (docs)

      allows logic before and after a command or subcommands run

    • via middleware (docs)
  • Method Interception

    CommandContext.InvocationPipeline to access method and params

Data Types#

docs

  • Primitives, Enums, Nullable<T> & Nullable Reference Types

  • Lists, Arrays and IEnumberable<T> for streaming

  • Password: mask value in logs and output with ***** (docs)

  • Any type with a

    • string constructor
    • static Parse(string) method
    • TypeConverter
  • Custom Type Descriptors

    Customize parsing and the type name shown in help and

  • Define allowed values by type

    Allowed values are shown in help and typo suggestions

Help#

  • Typo suggestions (docs)

  • Auto generated help (docs)

    Aliases: -? -h --help

  • Custom help generators (docs)

Dependency Injection#

docs

  • MicrosoftDependencyInjection
  • Autofac
  • SimpleInjector
  • Test resolver (docs)
  • Custom

Localization#

docs

  • supports IStringLocalizer

  • resx translation files available

    currently english only. PRs accepted

  • json translation files available

    currently english only. PRs accepted

  • [culture] directive (docs)

    set the culture for a command for manual verification

  • Test support (docs)

Extensibility#

  • Custom middleware (docs)
  • Custom directives (docs)
  • Custom token transformations (docs)
  • Custom parameter resolvers (docs)

Other#

  • Ctrl+C (docs)

  • Name casing (docs)

    consistent name casing via Humanizer

  • Spectre AnsiConsole (docs)

    ansi, colors, markup syntax, prompting, progress bars, tables. live displays, test capture, and much more

Arguments#

docs

  • Positional (operands)

  • Named (options)

    • Short and long names
    • Flags
    • bundling aka clubbing
  • Define arguments as parameters in methods

  • Define arguments as properties in POCOs

    • POCOs can be nested for easier reuse of infrastructural arguments, i.e. dryrun, verbosity, etc.
  • Option prefixes

    • Posix (default): - for short names and -- for long names
    • Windows (optional): / for both short and long names
    • Powershell (optional): - for long names
  • Argument separator --

    • as "end of options" indicator (docs)
    • or for pass-thru arguments (docs)
    • configure globally and per command
  • Capture unexpected arguments or throw exception (docs)

    • configure globally and per command

Argument Values#

  • Response Files (docs)

  • Piped Input with streaming (docs)

    • user can pipe to specific arguments
  • Negative numbers and other values starting with -

    Most frameworks treat these as options. We've got you covered.

  • split multi-value options by char (docs)

    • configure char globally and per option
  • Prompts (docs)

    • Hide passwords
    • Multi-entry for collections
    • Auto prompt for missing arguments (optional)
    • Spectre AnsiConsole integration for alternate prompting experience
  • Default from EnvVar (docs)

    values show as defaults in command help

  • Default from AppSetting (docs)

    • using [AppSetting] attribute
    • using naming conventions

      use command and arguments names as keys. eg. "--verbose": "true"

    • using IArgumentModel as configuration object

Validation#

  • Arity based on property and parameter definitions (docs)
  • DataAnnotations (docs)
  • FluentValidation (docs)

Testing#

  • BDD Framework (docs)

    Test an app as if run from the console

  • Supports parallel test

    the whole framework avoids static state to support parallel test runs

  • Test prompts (docs)

  • IConsole and SystemConsole covering most members of System.Console (docs)

    • TestConsole to capture output and mock piped and user input
    • Intercept Console.Out and Console.Error
    • Spectre AnsiConsole support also with AnsiTestConsole
  • IEnvironment and SystemEnvironment covering most members of System.Environment

    • TestEnvironment and .UseTestEnv extension for tests
  • TestDependencyResolver (docs)

    new TestDependencyResolver{ dbSvc, httpSvc }

  • TempFiles helper (docs)

    create and cleanup files used for tests

  • Capture State (docs)

    Capture state within a run to help test custom middleware components

Diagnostics#

  • App Version (docs)

    -v or --version

  • [debug] directive (docs)

    step into debugger

  • [time] directive (docs)

    outputs the execution time of a command

  • [parse] directive (docs)

    • show final values
    • show inputs and source

      original source of value, including > response file paths

    • show defaults and source

      including key if from EnvVar or AppSetting

  • Command logging (docs)

    show parse output and optionally system info and app config

  • Custom error handling (docs)