Commander.NET icon indicating copy to clipboard operation
Commander.NET copied to clipboard

Boolean arguments on Parent class are not set

Open bryanbcook opened this issue 3 years ago • 0 comments

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.

bryanbcook avatar Mar 04 '22 22:03 bryanbcook