Releases: dotmake-build/command-line
DotMake.CommandLine v3.1.0
-
Improved: Added new class
CliRunnableResultwhich derives fromCliResultand addsRunandRunAsyncmethods
running the handler for the called command.
Changed return type ofCli.ParseandCliParser.Parsemethods fromCliResulttoCliRunnableResult
So now you can do:var result = Cli.Parse<RootCliCommand>(); return result.Run(); //or var parser = Cli.GetParser<RootCliCommand>(); var result = parser.Parse(args); return result.Run();
-
Changed: Deprecated
CliContext.IsEmptyCommand()andCliContext.IsEmpty(), use new properties
!CliContext.Result.HasArgsand!CliContext.Result.HasTokensinstead.
These are better suited to be inCliResultand naming should better clarify the purpose. -
Fixed:
QualifiedSyntaxRewriterto support fully qualify generic name syntax likeArray.Empty<CustomClass>().
Changed handling so thatIdentifierNameSyntaxanywhere is converted to fully qualified. -
Fixed: Calling
Cli.Ext.ConfigureServiceswill reset existing service provider if it was already built or set,
so that changed service collection can take effect:var result = Cli.Parse<IStartupOptions>(args); var startupOptions = result.Bind<IStartupOptions>(); //This works now, the existing service builder (caused by Cli.Parse) will be reset Cli.Ext.ConfigureServices(services => { services.AddSingleton(startupOptions); services.AddSingleton<Dependency>(); }); await Cli.RunAsync<RootCommand>(args);
DotMake.CommandLine v3.0.0
-
Improved: Updated to final version
2.0.0ofSystem.CommandLine. -
Improved: Remove
SourceRevisionId(commit id) fromAssemblyInformationalVersion(<InformationalVersion>)
so that displayed app version and result of--versioncommand is clean and concise.
For example displayMyApp v2.0.0instead ofMyApp v2.0.0+b0f34d51fccc69fd334253924abd8d6853fad7aa.
DotMake.CommandLine v2.8.2
-
Fixed: All types in generated code will now be prefixed with global namespace
global::to prevent
CS0234 errors (namespace and type conflict compile errors) which can happen when user names a namespace part and a class same.
Example code to replicate the problem (now fixed), note the.TestApp,.System,.DotMake
as the final part of the namespace which triggered the problem:using DotMake.CommandLine; //Generated code should not fail to compile even if user uses some crazy namespaces namespace TestApp.Commands.TestApp { [CliCommand] public class TestAppCliCommand { [CliArgument(Arity = CliArgumentArity.ZeroOrMore)] public string Arg { get; set; } } } namespace TestApp.Commands.System { [CliCommand] public class SystemCliCommand { } } namespace TestApp.Commands.DotMake { [CliCommand] public class DotMakeCliCommand { } }
-
Improved: Documentation for
CliContext.IsEmptyCommand()andCliContext.IsEmpty()to emphasize the difference.
DotMake.CommandLine v2.8.1
- Fixed: Help was no longer printed for subcommands with a required argument with v2.8.0.
This happened due to the update to2.0.0-rc.1.25451.107of System.CommandLine.
There is a new propertyClearsParseErrorsinSynchronousCommandLineAction
which from now on, should be overridden to returntruefor our custom actions likeCustomHelpActionandVersionOptionAction.
Normally ourCliHelpBuilderchecks forParseResult.Errors.Count > 0to avoid printing help when there is a parsing error.
So asClearsParseErrorswas not set totrue,CliHelpBuilderwas not printing help as it thought there was a parse error
i.e.Required argument missing for command, even though-?or-hwas passed.
DotMake.CommandLine v2.8.0
- Improved: Updated to version
2.0.0-rc.1.25451.107of System.CommandLine. - Added:
MaxWidthproperty toCustomHelpAction
and ensure correctmaxWidthparameter inCliHelpBuilderconstructor if not specified.
DotMake.CommandLine v2.7.1
- Fixed: Foreground color is always white on macOS regardless of theme settings.
DotMake.CommandLine v2.7.0
- Updated to version 2.0.0-beta7.25380.108 of System.CommandLine.
DotMake.CommandLine v2.6.8
-
Added:
CommandandRootCommandproperties toCliParserclass:var parser = Cli.GetParser<RootCliCommand>(); //Access the command that is used to parse the command line input. var command = parser.Command; //Access the root of the command that is used to parse the command line input. //If parser.Command is already a root command, this will be same instance. //If it's a sub-command, it will be the root of that sub-command. var rootCommand = parser.RootCommand;
-
Fixed: SourceGenerator sometimes triggers a concurrency exception. Use
ConcurrentDictionaryforGenerationCounts. -
Fixed: Do not add auto name or alias for root commands as it can unnecessarily conflict with children.
DotMake.CommandLine v2.6.7
-
Fixed: Naming related settings were not being inherited correctly after level-2 sub-commands or above.
-
Fixed: NullReferenceException when invoking help output for a sub-command that had completions.
DotMake.CommandLine v2.6.6
-
Updated to version 2.0.0-beta6.25358.103 of System.CommandLine.
Also use exact version match with [] for PackageReference as future beta versions can break API. -
Added:
Orderproperty to[CliCommand],[CliDirective],[CliOption]and[CliArgument]attributes.
The order is used when printing the symbols in help and for arguments additionally effects the parsing order.
When not set (or is0- the default value), the symbol order is determined based on source code ordering.[CliCommand(Description = "A root cli command with custom order")] public class OrderedCliCommand { [CliOption(Description = "Description for Option1", Order = 2)] public string Option1 { get; set; } = "DefaultForOption1"; [CliOption(Description = "Description for Option2", Order = 1)] public string Option2 { get; set; } = "DefaultForOption2"; [CliArgument(Description = "Description for Argument1", Order = 2)] public string Argument1 { get; set; } = "DefaultForArgument1"; [CliArgument(Description = "Description for Argument2", Order = 1)] public string Argument2 { get; set; } = "DefaultForArgument2"; [CliCommand(Description = "Description for sub-command1", Order = 2)] public class Sub1CliCommand { } [CliCommand(Description = "Description for sub-command2", Order = 1)] public class Sub2CliCommand { } }
-
Improved: Nested classes with container class not having
[CliCommand]attribute, can now be used. -
Fixed: If there is no HelpName for option and if option is not a flag, show the
<argument>next to it, for example:Options: --settingsfile <settingsfile> Path to settings file [required]