Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: allow marking args/flags/options as global or exclusive to no subcommands #80

Open
ZoomRmc opened this issue Jun 1, 2022 · 1 comment

Comments

@ZoomRmc
Copy link
Contributor

ZoomRmc commented Jun 1, 2022

It would be very useful to be able to have two types of arguments/flags/options:

  1. Common to all invocations of the program, including all subcommands or no subcommands
  2. Conflicting with any subcommands

Syntax proposal:

var p = newParser:
  flag("-n", "--dryrun") # common
  rootCommand:
    arg("input") # can't be used with `frobnicate`
  command("frobnicate"):
    flag("-b")
    arg("subcommandInput")
@iffy
Copy link
Owner

iffy commented Jun 2, 2022

Thanks for this suggestion!

Note to self (or whoever does it) when doing this: this might be a good opportunity to add a default command option, too. So you can explicitly run ./prog foo -a but if foo is the default command ./prog -a is equivalent.

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

No branches or pull requests

2 participants