I have an argument for one of my commands which represents a path/ID to a resource. I want to be able to provide tab-completion to allow easily cycling between existing paths/IDs, but I don't want these values to be enumerated if I run --help for my command.
I'm thinking this could be an option on the CompletionItem object, like a boolean property called Hidden. You could then do something this like.
var myarg = new Option<string>("--id", "The id of the item to get");
myarg.AddCompletions(ctx => GetIdSuggestions(ctx));
private IEnumerable<CompletionItem> GetIdSuggestions(CompletionContext ctx)
=> GetExistingIds(prefix: ctx.WordToComplete).Select(id => new CompletionItem(id) { Hidden = true });
and then when you attempt to run the command from the terminal
it will cycle through existing IDs returned by my method, but when I run
It will still only print out
Options:
--id <id> The id of the item to get
rather than
Options:
--id <id1|id2|id3|id4|...> The id of the item to get
I have an argument for one of my commands which represents a path/ID to a resource. I want to be able to provide tab-completion to allow easily cycling between existing paths/IDs, but I don't want these values to be enumerated if I run
--helpfor my command.I'm thinking this could be an option on the
CompletionItemobject, like abooleanproperty calledHidden. You could then do something this like.and then when you attempt to run the command from the terminal
it will cycle through existing IDs returned by my method, but when I run
It will still only print out
rather than