Skip to content

Version 4

Compare
Choose a tag to compare
@bilal-fazlani bilal-fazlani released this 13 May 09:13
· 434 commits to master since this release
1fea7d6

Nullable Reference Types

The library has been updated to support Nullable Reference Types

Default behavior changes

Version 4 is removing obsolete members and changing default behaviors made possible since the v3 was introduced.

  • default AppSettings.Help.ExpandArgumentsInUsage to true.
    • arguments are expanded in the usage section of help.
      • old: add [options] [arguments]
      • new: add [options] <x> <y>
  • default AppSettings.DefaultArgumentSeparatorStrategy to EndOfOptions. See Argument Separator for details.
    • Help will append [[--] <arg>...] to the usage example when DefaultArgumentSeparatorStrategy=PassThru
  • make AppSettings.LongNameAlwaysDefaultsToSymbolName the only behavior and remove the setting. LongName can be removed with [Option(LongName=null)].
    • Look for places in your apps where [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.
  • make AppSettings.GuaranteeOperandOrderInArgumentModels the only behavior and remove the setting.
  • enable CommandLogger in .UseDefaultMiddleware() as cmdlog directive. This can be useful for diagnostics.
  • Command.FindOption will throw an exception if the alias is for an operand or subcommand instead of an option. Previously it would return null.

Added

  • The type MiddlewareSteps declares most of the framework defined middleware to make it easier to inject your custom middleware in the desired order.

Changed

  • When registering middleware, the OrderInStage parameter has been changed from int to short.

Moved

  • 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.

Removed or Replaced

  • 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 classes
  • ServicesExtensions.GetOrAdd<T> - use ContextDataExtensions.GetOrAdd<T>