Closed
Description
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
app command --id <TAB>
it will cycle through existing IDs returned by my method, but when I run
app command --help
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
Metadata
Metadata
Assignees
Labels
No labels