Skip to content

Mark flag mutually exclusive and required #1761

@shanduur-auto

Description

@shanduur-auto

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/flags-argsChanges to functionality around command line flags and args

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions