Skip to content

Features#

Commands#

  • Define commands as methods
  • Parameter Resolvers

    Inject console and other contexts as a parameter: IConsole, CommandContext, CancellationToken & IPrompter by default.

  • Infinite nesting of subcommands

    • Nested classes
    • Composed classes
    • Commands can define arguments that appear in all subcommands
  • Command Interception

    • via interceptor methods (aka hooks)

      allows logic before and after a command or subcommands run

    • via middleware
  • Method Interception

    CommandContext.InvocationPipeline to access method and params

Data Types#

  • Primitives, Enums, Nullable<T> & Nullable Reference Types
  • Lists, Arrays and IEnumberable<T> for streaming
  • Password: mask value in logs and output with *****
  • 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
  • Auto generated help

    Aliases: -? -h --help

  • Custom help generators

Dependency Injection#

  • MicrosoftDependencyInjection
  • Autofac
  • SimpleInjector
  • Test injector
  • Custom

Localization#

  • supports IStringLocalizer
  • resx translation files available

    currently english only. PRs accepted

  • json translation files available

    currently english only. PRs accepted

  • [culture] directive

    set the culture for a command for manual verification

  • Test support

Extensibility#

  • Custom middleware
  • Custom directives
  • Custom token transformations
  • Custom parameter resolvers

Other#

  • Ctrl+C
  • Name casing

    consistent name casing via Humanizer

  • Spectre AnsiConsole

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

Arguments#

  • 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 Values#

  • Response Files
  • Piped Input with streaming
  • Negative numbers and other values starting with -

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

  • Prompts
    • Hide passwords
    • Multi-entry for collections
    • Auto prompt for missing arguments (optional)
    • Spectre AnsiConsole integration for alternate prompting experience
  • Default from EnvVar
  • Default from AppSetting
    • using [AppSetting] attribute
    • using naming conventions
    • using IArgumentModel as configuration object

Validation#

  • FluentValidation for argument models
  • DataAnnotations

Testing#

  • BDD Framework

    Test an app as if run from the console

  • Supports parallel test

    the whole framework avoids static state to support parallel test runs

  • IConsole and SystemConsole covering most members of System.Console
    • TestConsole to capture output and mock piped and user input
    • Spectre AnsiConsole support also with AnsiTestConsole
  • TestDependencyResolver

    new TestDependencyResolver{ dbSvc, httpSvc }

  • TempFiles helper

    create and cleanup files used for tests

  • Capture State

    Capture state within a run to help test custom middleware components

Diagnostics#

  • App Version

    -v or --version

  • [debug] directive

    step into debugger

  • [time] directive

    outputs the execution time of a command

  • [parse] directive
    • 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

    show parse output and optionally system info and app config

Back to top