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
- supports the pattern you prefer:
-
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
-
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
*****
(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#
Dependency Injection#
- MicrosoftDependencyInjection
- Autofac
- SimpleInjector
- Test resolver (docs)
- Custom
Localization#
Extensibility#
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
- Posix (default):
-
Argument separator
--
-
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#
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)