cobra
cobra copied to clipboard
Mark flag mutually exclusive and required
Hi!
I want to ask, if there is an option to mark one of n
of the mutually exclusive flags required? This means there must appear exactly one of the n
flags, otherwise an error should be printed.
For example:
# this should print contents from file:
$ echo -f ./file.txt
hello world
# this should act as a regular echo:
$ echo -i "hello world"
hello world
# this should print help and info about missing required flags:
$ echo
Error: one of mutually exclusive required flag(s) not set: "f", "i"
Usage:
echo [flags]
Hi @shanduur-auto. Currently there is no special support from Cobra for what you are asking. You would have to do the verification yourself in your program.
The Cobra project currently lacks enough contributors to adequately respond to all issues. This bot triages issues and PRs according to the following rules:
- After 60d of inactivity, lifecycle/stale is applied. - After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied and the issue is closed. You can:
- Make a comment to remove the stale label and show your support. The 60 days reset. - If an issue has lifecycle/rotten and is closed, comment and ask maintainers if they'd be interseted in reopening
Fixed by @marevers in #1952