Skip to content

Mark options as required together #1802

@whitlockjc

Description

@whitlockjc

I have a use case where I could like to require my command options to be conditionally required, and exclusive. For example, let's say my testing command has three options:

  • -x, --one <number>
  • -y, --two <number>
  • -z, --three <number>

I'd like to make it where the command either needs -x provided or both -y and -z together. The .conflicts() support makes it easy to ensure that they aren't used together where they shouldn't be but there doesn't seem to be a way to mark -x as required when -y and/or -z isn't used, nor is there a way to mark it such that both -y and -z must be used in combination together when -x isn't used.

I could craft a way to do this myself, and I've searched the project to see if this has been discussed before, but I can't find anything.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions