I have the following setup:
public class CommandArgs
{
[Parameter("verbose", Required = Required.No)
public bool Verbose { get; set; }
[Command("go")]
public GoCommand GoCmd { get; set; }
}
public class GoCommand : ICommand
{
[Parameter("x")]
public string X { get; set; }
public void Execute(object parent)
{
var globalArgs = (CommandArgs)parent;
Console.Writeline(globalArgs.Verbose); // <-- always false
}
}
Expected: the value of the CommandArgs.Verbose should be set to true when --verbose is supplied on the command-line.
Actual: the value is ignored.
If I change this code and move the Verbose flag to the GoCommand class, it does get picked up correctly.
I'm using .NET Core 5 in Visual Studio 2022.
I have the following setup:
Expected: the value of the
CommandArgs.Verboseshould be set to true when--verboseis supplied on the command-line.Actual: the value is ignored.
If I change this code and move the
Verboseflag to theGoCommandclass, it does get picked up correctly.I'm using .NET Core 5 in Visual Studio 2022.