CommandLineUtils
CommandLineUtils copied to clipboard
Make HelpOption discovery work same as for any other option
At the moment custom command options are searched inside command instance and any parent up the inheritance chain
public IEnumerable<CommandOption> GetOptions()
{
var expr = Options.AsEnumerable();
var rootNode = this;
while (rootNode.Parent != null)
{
rootNode = rootNode.Parent;
expr = expr.Concat(rootNode.Options.Where(o => o.Inherited));
}
return expr;
}
But for HelpOption search stops if parent does not have it, even though it may be set further up the chain
public CommandOption? OptionHelp
{
get
{
if (_optionHelp != null)
{
return _optionHelp;
}
return Parent?.OptionHelp?.Inherited == true
? Parent.OptionHelp
: null;
}
internal set => _optionHelp = value;
}
It would be more clear, as for me, if OptionHelp would follow same discovery logic as used for other options.
I have hit some inconvenience working with this when trying to create extension method for CommandLineApplication that would clear duplicate options from subcommands if any.
I would be open to a pull request that implements this. I've marked as help-wanted as I'm not planning to implement on my own, but this seems like a valuable enhancement.
https://docs.github.com/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please comment if you believe this should remain open, otherwise it will be closed in 14 days. Thank you for your contributions to this project.
Closing due to inactivity. If you are looking at this issue in the future and think it should be reopened, please make a commented here and mention natemcmaster so he sees the notification.