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

Showing global options in command parsers #138

Closed
chrisdone opened this issue Jun 9, 2015 · 8 comments
Closed

Showing global options in command parsers #138

chrisdone opened this issue Jun 9, 2015 · 8 comments

Comments

@chrisdone
Copy link

Is it possible to have e.g. foo --help produce

Usage: <interactive> [--version] [--help]  [--verbose ARG] COMMAND

Available options:
  --version                Show version
  --help                   Show this help text
  --verbose ARG            Set verbosity

Available commands:
  dothing                    do the thing

and then foo dothing --help produce

Usage: <interactive> [--verbose ARG] dothing
  do the thing

like that? So that --verbose is still listed because it's a global option but applies to dothing too?

@edsko
Copy link

edsko commented Jul 8, 2015

+1 :)

edsko added a commit to haskell/hackage-security that referenced this issue Jul 8, 2015
Unfortunately this help does not show global options; see
pcapriotti/optparse-applicative#138 .
@bollmann
Copy link

+1

@HuwCampbell
Copy link
Collaborator

I've made some changes to how contexts are carried through, so this should be easier now.

@nomeata
Copy link

nomeata commented Dec 25, 2015

+1

@nomeata
Copy link

nomeata commented Jan 2, 2016

I am very interested in having a fix for this. Does anyone maybe have a somewhat doable workaround for this?

@borsboom
Copy link

borsboom commented Jan 6, 2016

There is a workaround, although it's a bit of work. Basically you have to add the global options parser both in the outer parser and to every subcommand parser, and then you combine the "outer" global options with the "inner" global options (having the inner options take precedence). You also have to make sure you set (prefs noBacktrack) for this case to avoid confusing behaviour. We do this in stack, and the Options.Applicative.Complicated module has most of the guts of that.

@nomeata
Copy link

nomeata commented Jan 6, 2016

Hmm. Sounds as if its almost easier to only have local options then.

@bitc
Copy link

bitc commented Dec 16, 2017

Why was this issue closed? There still doesn't seem to be a way to do this (apart from the complicated workaround of @borsboom)

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 a pull request may close this issue.

7 participants