Skip to content

Conversation

DannyBen
Copy link
Member

@DannyBen DannyBen commented Mar 1, 2021

Closes #65


TODO:

  • Implementation
  • Second opinion test
  • Update README
  • Add example
  • Implement specs

This PR allows defining allowed: [value1, value2] for flag items

# bashly.yml
flags:
- long: --user
  short: -u
  arg: NAME
  allowed: [user, admin]
  # required: true
  default: user
  help: "User name"

This will:

Exit with an error unless the provided value is in the whitelist:

$ ./login --user asd
--user must be one of: user, admin

Show the allowed default values in the usage text:

$ ./login --help
...
Options:
  --user, -u NAME
    User name
    Allowed: user, admin
    Default: user
...

As usual, output strings are configurable.

@DannyBen DannyBen merged commit 0c737ff into master Mar 2, 2021
@DannyBen DannyBen deleted the add/flag-whitelist branch March 2, 2021 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Support allowed argument values as an option
1 participant