I'm looking to implement a Flag which can have a few predefined values.
E.g.
mycli --output json
mycli --output xml
Is there a way to implement this using the existing flags while also informing the user of the cli what are the available options?
If not would it make sense to add this OptionFlag? I would be happy to make a PR for that with some guidance.
To rephrase the question - are if asking if there's a builtin way to implement a flag that gives users a set of choices from a predefined list? Something like Choices: []string{'json', 'xml'}?
@lynncyrin yes that is exactly what I meant.
Makes sense! There's no obvious builtin way to implement this, but I've implemented a few "manual" versions of it. I don't happen to have that code on-hand, though.
@lynncyrin would be great if you could dig it up and share a snippet here with the community. I'm happy to take that snippet of your further to integrate it here.
Ping @lynncyrin
This was previously requested in #620
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.
Not stale
This issue or PR has been bumped and is no longer marked as stale! Feel free to bump it again in the future, if it's still relevant.