Hi,
I am very glad to see a new nuget package, thanks for that. I am facing an issue which seems to be a bug to me. The parent options don't seem to be correctly passed anymore to sub-commands.
I created a small sample (copied below) to reproduce the issue. When executed with "subcommand" with the previous version 19405.1, it produced:
The value for --int-option is: 12
The value for --int-suboption is: 123
But with the new version 19573.2, it now produces:
The value for --int-option is: 0
The value for --int-suboption is: 123
I was using some intermediate version (19420.2) which was OK. I didn't try to identify when this change happened.
Is this a regression?
Thank you
using System;
using System.CommandLine;
using System.CommandLine.Invocation;
namespace TestCmdline
{
class Program
{
static int Main(string[] args)
{
var rootCommand = new RootCommand
{
new Option("--int-option")
{
Argument = new Argument<int>(defaultValue: () => 12)
}
};
rootCommand.Description = "My sample app";
rootCommand.Handler =
CommandHandler.Create<int>((intOption) =>
{
Console.WriteLine($"The value for --int-option is: {intOption}");
});
var subCommand = new Command("subcommand");
rootCommand.Add(subCommand);
subCommand.AddOption(
new Option("--int-suboption")
{
Argument = new Argument<int>(defaultValue: () => 123)
});
subCommand.Handler =
CommandHandler.Create<int, int>((intOption, intSuboption) =>
{
Console.WriteLine($"The value for --int-option is: {intOption}");
Console.WriteLine($"The value for --int-suboption is: {intSuboption}");
});
return rootCommand.InvokeAsync(args).Result;
}
}
}
This looks like a regression. Could you provide the command line that produces the output above?
I called the project TestCmdline, so I just call:
TestCmdline.exe subcommand
I think i have the same problem. For a string argument i get empty string whatever i type and for integers i get 0. Even if i use arguments only in subcommand
New packages will be available on nuget.org momentarily.