You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A clear and concise description of what the bug is.
I believe this is the same bug as mentioned in #428, where command options from parent settings aren't being taken into account / parsed.
I'm trying to pass in command options that are stored in a parent settings class, but these command options all appear to be ignored.
using Spectre.Console.Cli;namespace Repro;publicclassBranchSettings:CommandSettings{[CommandOption("--my-value")]publicstringMyValue{get;set;}=string.Empty;}publicclassBranchedCommandSettings:BranchSettings{}publicclassBranchedCommand:Command<BranchedCommandSettings>{publicoverrideintExecute(CommandContextcontext,BranchedCommandSettingssettings)=>0;}
And my program file:
using Repro;using Spectre.Console.Cli;CommandAppapp=new();
app.Configure(config =>{ config.ValidateExamples(); config.AddBranch<BranchSettings>("branch",user =>{ user.SetDescription("Branch."); user.AddCommand<BranchedCommand>("command").WithDescription("Command under a branch.").WithExample("branch","command","--my-value","abc");});});return app.Run(args);
I'm experiencing the same issue. It seams that the derived options are not honored in the parent class.
Or perhaps I'm not doing it wrong, but this is the most basic version that looks like the example from the documentation.
publicoverrideasyncTask<int>ExecuteAsync(CommandContextcontext,CreateCustomerSettingssettings){
AnsiConsole.MarkupLine($"Creating new customer [[{settings.CustomerName}]].");await _customerService.CreateNewCustomerAsync(settings.CustomerName);
AnsiConsole.MarkupLine("Done");return0;}
But the console does not show the options. And the value is always the default value.
As you can see, the output option is not show.
c:\Test> dotnet run -- customer create -h
DESCRIPTION:
Create customer the the customers table.
USAGE:
aztai customer create <CUSTOMER_NAME> [OPTIONS]
ARGUMENTS:
<CUSTOMER_NAME>
OPTIONS:
-h, --help Prints help information
Information
Describe the bug
A clear and concise description of what the bug is.
I believe this is the same bug as mentioned in #428, where command options from parent settings aren't being taken into account / parsed.
I'm trying to pass in command options that are stored in a parent settings class, but these command options all appear to be ignored.
And my program file:
To Reproduce
I have created a minimum reproducible example here: https://github.com/robcao/spectre-console-branch-inheritance
To reproduce, download the example, navigate to the
repro
directory, and rundotnet run
.The application fails with the following exception:
Expected behavior
A clear and concise description of what you expected to happen.
I expect command options defined on parent setting classes to be bound.
When running
dotnet run branch command --my-value abc
, I would expect the following:BranchedCommand .Execute
method, the value ofBranchedCommandSettings.MyValue
should beabc
.Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: