Skip to content

Conditional arguments #19

Description

@mottosso

Let some arguments depend on other arguments.

parser.add_argument("colored", default=False)
parser.add_argument("color", condition=lambda: parser["colored"] == True)

For example, disable or hide color if colored is False.

Syntax is still unclear, could also be:

parser.add_argument("color", dependencies=["colored"])

Whereby any "dependency" is tested with return bool(arg), such that each argument can override __nonzero__ and __bool__ to control the behavior.

Also needs some indication of what to do if the condition is False.

parser.add_argument("color", condition=, condition_behavior=Hide)
# Or "Disable" or "Ignore"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions