Open mas-co opened 3 years ago
+1, I don't use DragonFruit and have the same issue. Copied code from the sample app and added a little bit of extra at the end:
var rootCommand = new RootCommand
{
new Option<int>(
"--int-option",
getDefaultValue: () => 42,
description: "An option whose argument is parsed as an int"),
new Option<bool>(
"--bool-option",
"An option whose argument is parsed as a bool"),
new Option<FileInfo>(
"--file-option",
"An option whose argument is parsed as a FileInfo")
};
rootCommand.Description = "My sample app";
// Note that the parameters of the handler method are matched according to the names of the options
rootCommand.Handler = CommandHandler.Create<int, bool, FileInfo>((intOption, boolOption, fileOption) =>
{
Console.WriteLine($"The value for --int-option is: {intOption}");
Console.WriteLine($"The value for --bool-option is: {boolOption}");
Console.WriteLine($"The value for --file-option is: {fileOption?.FullName ?? "null"}");
});
return await new CommandLineBuilder(rootCommand)
.UseHelp()
.UseVersionOption()
.Build()
.InvokeAsync(args);
Yields:
$ ./CliApp --version
--version option cannot be combined with other arguments.
CliApp
My sample app
Usage:
CliApp [options]
Options:
--int-option <int-option> An option whose argument is parsed as an int [default: 42]
--bool-option An option whose argument is parsed as a bool
--file-option <file-option> An option whose argument is parsed as a FileInfo
-?, -h, --help Show help and usage information
--version Show version information
Version:
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21216.1" />
I pulled the latest code and tried this locally - the issue doesn't occur. It's only a problem in the latest NuGet package.
I also found the PR that fixed this: https://github.com/dotnet/command-line-api/pull/1270. So I do believe this issue can be closed.
Can someone advise when the next package will be published please?
After updating, it's still an issue in 2.0.0-beta1.21308.1 .
@cerebrate Are you using DragonFruit or System.CommandLine directly? I'm not able to repro this.
@jonsequitur System.CommandLine directly.
Specific code is here, if it helps to repro it: https://github.com/arkane-systems/genie/blob/49980995b9de4988c897c5740f302a26632324c2/binsrc/genie/Program.cs#L82-L150
Hello!
There seems to be a problem with the "--version" option with DragonFruit (0.3.0-alpha.21216.1). Using the "Building your first app with System.CommandLine.DragonFruit" as an example:
output of the "help" command is:
typing "ConsoleApp1 --version" yields:
I would expect it to simply work like the --help menu, but display the version number.