-
Notifications
You must be signed in to change notification settings - Fork 841
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
Add --verbose flag #217
Comments
Try |
Also make sure you list it on the
|
If you run |
There is already |
Yeah, that's because those options aren't command specific. We can possibly do something in optparse-simple to re-inject these somehow. |
@ndmitchell Confirm? We already have -v, but I added --verbose as the long form. |
Oh, let me also do something about showing global options on subcommands. |
@snoyberg @ndmitchell I don't yet see a way to make optparse-applicative print out global options for a subcommand's The below is the best I can achieve, by moving all global options into each command parser, if there are any. In the case of no commands: λ> let noCommandsCase args = do (opts,()) <- withArgs args (simpleOptions "" "" "" (optional (strOption (long "verbose"))) empty); print opts
λ> noCommandsCase []
Nothing
λ> noCommandsCase ["--help"]
Usage: <interactive> [--version] [--help] [--verbose ARG]
Available options:
--version Show version
--help Show this help text
*** Exception: ExitSuccess
λ> noCommandsCase ["--verbose=true"]
Just "true" In the case of commands specified: λ> let commandsCase args = do (opts,run) <- withArgs args (simpleOptions "" "" "" (optional (strOption (long "verbose"))) (addCommand "build" "do the thing" pure (pure ()))); print opts; run
λ> commandsCase []
Usage: <interactive> [--version] [--help] COMMAND
Available options:
--version Show version
--help Show this help text
Available commands:
build do the thing
*** Exception: ExitSuccess
λ> commandsCase ["build","--help"]
Usage: <interactive> build [--verbose ARG]
do the thing
*** Exception: ExitSuccess
λ> commandsCase ["build","--verbose=true"]
Just "true"
λ> |
Perhaps it's worth opening up an issue against optparse-applicative on this? |
I'm not sure that what we're trying to do makes sense in the optparse-applicative world, but I'll open an issue to ask. |
The |
Seems like it would help diagnose issues such as #216 if you gave a complete listing of everything you were doing, particularly what command lines you run.
The text was updated successfully, but these errors were encountered: