A modern framework for building modern CLI apps
https://github.com/bilal-fazlani/commanddotnet/issues/318#issuecomment-970051600
remove nuget package refs no longer required after move to net5.0
CommandDotNet now supports Nullable reference types (NRT) when calculating Arity. Arityfor.Minimum will be 0 for NRTs.
CommandDotNet targets net5.0 instead of netstandard2.0. This will allow us to take advantage of new framework features. We're holding off on net6.0 at the moment because it's new enough many companies will not be able to adopt it yet. We are eager to take advantage of Source Generators though so we will likely also target net6.0 in early 2022.
Added support for Windows and Powershell conventions when using options
/help
and /h
for windows conventions-help
for long names for powershell conventionsThese are not enabled by default. Enable by setting AppSettings.Parser.AllowBackslashOptionPrefix
and/or AppSettings.Parser.AllowSingleHyphenForLongNames
= true
.
Previously, negative numbers were only support when proceeded by :
or =
, eg --amount=-15
which meant they could only be used with options. CommandDotNet now supports --amount -15
or -15
as an operand.
Overhaul of IConsole, now covering most the System.Console members. Converted In, Out and Error to TextReader and TextWriter to match System.Console. This includes updates to the TestConsole and AnsiTestConsole for the Spectre integration.
Overhaul of IConsole, now covering most the System.Console members. Converted In, Out and Error to TextReader and TextWriter to match System.Console. This includes updates to the TestConsole and AnsiTestConsole for the Spectre integration.
The behavior for calculating Arity and prompting on missing arguments changes as these arguments were not previously considered nullable and so the Arity has changed to expect a minimum of 0 instead of 1
Using the UseArgumentPrompter will now work as expected when using NRTs. They will no longer prompt the user.
This has been a confusing method. It currently evaluates as arity.Maximum == 0
but it intuitively it makes more sense as arity.Minimum == 0
.
ArgumentArity.AllowsNone() has been changed to arity.Minimum == 0
ArgumentArity.RequiresNone() has been added for arity.Maximum == 0
.
DefaultMethodAttribute
. Use DefaultCommandAttribute
instead.appRunner.UsePrompting(...)
extension method. Use .UseIPrompter
and .UseArgumentPrompter
instead.BooleanMode.Unknown
. Use either Implicit
, Explicit
, or BooleanMode?
instead.Several updates to localizeable Resources. Changed a few member names for clarity and anded a several new members.
Now takes AppSettings to support /
and -
option prefixes.
To support negative numbers and prefixing options with /
and -
, we needed more context from the command definition so determining if a token is an option or value has been moved to the command parser. Token transformation no longer distinguishes options vs values.
added IsInterceptor property to distinguish between command and interceptor invocations
ArgumentArity.Default(Type, ...)
. Use ArgumentArity.Default(IArgument)
instead. This is a reversal of previous direction, but the addition of IArgument.BooleanMode makes this reliable.FindOption(string alias)
. Use Find<Option>(string alias)
instead.command.GetIgnoreUnexpectedOperands(AppSettings)
. Use command.IgnoreUnexpectedOperands
as it now defaults from AppSettings.command.GetArgumentSeparatorStrategy(AppSettings)
. Use command.ArgumentSeparatorStrategy
as it now defaults from AppSettings.Option.ShowInHelp
. Use Option.Hidden
instead. There were cases where this had meaning outside of generating help.The library has been updated to support Nullable Reference Types
Version 4 is removing obsolete members and changing default behaviors made possible since the v3 was introduced.
AppSettings.Help.ExpandArgumentsInUsage
to true.
add [options] [arguments]
add [options] <x> <y>
AppSettings.DefaultArgumentSeparatorStrategy
to EndOfOptions
. See Argument Separator for details.
[[--] <arg>...]
to the usage example when DefaultArgumentSeparatorStrategy=PassThru
AppSettings.LongNameAlwaysDefaultsToSymbolName
the only behavior and remove the setting. LongName
can be removed with [Option(LongName=null)]
.
[Option(ShortName="a")]
with setting a LongName. If you don't want a LongName then add LongName=null
otherwise the long name will default from the parameter or property name.AppSettings.GuaranteeOperandOrderInArgumentModels
the only behavior and remove the setting.
.UseDefaultMiddleware()
as cmdlog
directive. This can be useful for diagnostics.MiddlewareSteps
declares most of the framework defined middleware to make it easier to inject your custom middleware in the desired order.int
to short
.CommandDotNet.Directives.Parse.ParseReporter
- moved to CommandDotNet.Diagnostics.Parse.ParseReporter
CommandDotNet.Directives.Debugger
- moved to CommandDotNet.Diagnostics.Debugger
AppConfig.CancellationToken
- moved to CommandDotNet.CancellationToken
. This enables running nested commands within an interactive session. See Ctrl+C and CancellationToken for more details.AppSettings
MethodArgumentMode
- replaced by DefaultArgumentMode
ThrowOnUnexpectedArgument
- replaced by IgnoreUnexpectedArguments
AllowArgumentSeparator
- was never used for functionality, only to show --
in help.HelpTextStyle
- replaced by Help.TextStyle
Help
GlobalTool
- replaced by UsageAppName
VersionInfo
- replaced by AppInfo
ApplicationMetadataAttribute
- replaced by CommandAttribute
ArgumentAttribute
- replaced by OperandAttribute
ArgumentMode.Parameter
- replaced by Operand
InjectPropertyAttribute
- v3 made ctor injection possible and that should be used.Command
, Option
, Operand
ctor taking with Command parent
parameter. Parent
is now assigned by adding to a command.OptionAttribute
Inherited
- replaced by AssignToExecutableSubcommands
Option
DefaultValue
- use Option.Default
Inherited
- replaced by AssignToExecutableSubcommands
Operand
DefaultValue
- use Option.Default
IArgument
DefaultValue
- use Option.Default
appRunner.UseDefaultsFromConfig
extension method that returns string, in favor of method with same name returning ArgumentDefault
TokenCollection
public ctor - Use Tokenizer.Tokenize
extension method to generate tokens and TokenCollection.Transform
to transform them. Ensures source tokens are correctly mapped.AnsiConsole
- no longer supported. Use a package like ColorConsole or Pastel.MiddlewareSteps.Help.Stage
& MiddlewareSteps.Help.Order
- replaced by nested MiddlewareSteps.Help
classesServicesExtensions.GetOrAdd<T>
- use ContextDataExtensions.GetOrAdd<T>
see What's new in version 3 for an overview of the updates
Breaking change for preview:
UseSimpleInjector signature changed: https://github.com/bilal-fazlani/commanddotnet/commit/ddf529590455e3671f59f7035011c2edb90c322e
change your usages as follows useResolveForArgumentModel = true -> argumentModelResolveStrategy = ResolveStrategy.Resolve useTryResolveForCommandClass = true -> commandClassResolveStrategy = ResolveStrategy.TryResolve
Breaking change for preview:
UseMicrosoftDependencyInjection signature changed: https://github.com/bilal-fazlani/commanddotnet/commit/ddf529590455e3671f59f7035011c2edb90c322e
change your usages as follows useResolveForArgumentModel = true -> argumentModelResolveStrategy = ResolveStrategy.Resolve useTryResolveForCommandClass = true -> commandClassResolveStrategy = ResolveStrategy.TryResolve
Breaking change for preview:
UseAutofac signature changed: https://github.com/bilal-fazlani/commanddotnet/commit/ddf529590455e3671f59f7035011c2edb90c322e
change your usages as follows useResolveForArgumentModel = true -> argumentModelResolveStrategy = ResolveStrategy.Resolve useTryResolveForCommandClass = true -> commandClassResolveStrategy = ResolveStrategy.TryResolve
Breaking change for preview:
UseDependencyInjector signature changed: https://github.com/bilal-fazlani/commanddotnet/commit/ddf529590455e3671f59f7035011c2edb90c322e
change your usages as follows useResolveForArgumentModel = true -> argumentModelResolveStrategy = ResolveStrategy.Resolve useTryResolveForCommandClass = true -> commandClassResolveStrategy = ResolveStrategy.TryResolve