Context:
I am using spectre.console. I have the following configuration code:
app.Configure(config =>
{
// Add
config.AddBranch<AddSettings>("add", add =>
{
add.SetDescription("Add a package or reference to a .NET project");
add.AddCommand<AddPackageCommand>("package");
add.AddCommand<AddReferenceCommand>("reference");
});
});
Now I would like to introduce LogCommandSettings
public class LogCommandSettings : CommandSettings
{
[CommandOption("--logFile")]
[Description("Path and file name for logging")]
public string LogFile { get; set; }
// ...and more...
}
If I inherit AddSettings : LogCommandSetting
it works fine, however the position of --logFile
option will be fixed before the subcommands like the following:
myapp add <PROJECT> --logLevel=d package <PACKAGE> # working
myapp add <PROJECT> package <PACKAGE> --logLevel=d # error
I do understand why it is working this way, this is not the question.
Question
I would like to have the logging options at the end of the command line. (yes it is questionable: why? ...still I feel it more clear CLI)
I can not inherit CommandSettings
of the AddPackageCommand
and AddReferencCommand
from LogCommandSettings
, because those classes - being subcommand of 'add' they must inherit from AddSettings
. It seems I must fall to the sin of copy and paste and explicit copy the properties from LogCommandSettings
to every single leaf level subcommands's Settings
, which count could be dozens...