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

Closed
ndmitchell opened this Issue Jun 9, 2015 · 11 comments

Comments

Projects
None yet
3 participants
@ndmitchell
Contributor

ndmitchell commented Jun 9, 2015

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.

@snoyberg

This comment has been minimized.

Contributor

snoyberg commented Jun 9, 2015

Try --verbosity debug. @chrisdone what do you think about making --verbose a synonym for it?

@ndmitchell

This comment has been minimized.

Contributor

ndmitchell commented Jun 9, 2015

Also make sure you list it on the --help output:

C:\Neil\hlint>stack build --verbose
Usage: stack build [TARGET] ([--library-profiling] | [--no-library-profiling])
                   ([--executable-profiling] | [--no-executable-profiling])
                   ([--optimizations] | [--no-optimizations]) [--dry-run]
                   [--ghc-options OPTION] [--flag PACKAGE:[-]FLAG]
  Build the project(s) in this directory/configuration
@snoyberg

This comment has been minimized.

Contributor

snoyberg commented Jun 9, 2015

If you run stack --help, it tells you about global options, but it seems very peculiar that we don't show all options for stack build --help. @chrisdone does that need to be fixed in optparse-simple?

@snoyberg snoyberg added this to the Third release milestone Jun 9, 2015

@chrisdone

This comment has been minimized.

Member

chrisdone commented Jun 9, 2015

There is already -v?

@chrisdone

This comment has been minimized.

Member

chrisdone commented Jun 9, 2015

If you run stack --help, it tells you about global options, but it seems very peculiar that we don't show all options for stack build --help. @chrisdone does that need to be fixed in optparse-simple?

Yeah, that's because those options aren't command specific. We can possibly do something in optparse-simple to re-inject these somehow.

chrisdone added a commit that referenced this issue Jun 9, 2015

@chrisdone

This comment has been minimized.

Member

chrisdone commented Jun 9, 2015

@ndmitchell Confirm? We already have -v, but I added --verbose as the long form.

@chrisdone

This comment has been minimized.

Member

chrisdone commented Jun 9, 2015

Oh, let me also do something about showing global options on subcommands.

@chrisdone

This comment has been minimized.

Member

chrisdone commented Jun 9, 2015

@snoyberg @ndmitchell I don't yet see a way to make optparse-applicative print out global options for a subcommand's --help output.

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"
λ> 
@snoyberg

This comment has been minimized.

Contributor

snoyberg commented Jun 9, 2015

Perhaps it's worth opening up an issue against optparse-applicative on this?

@chrisdone

This comment has been minimized.

Member

chrisdone commented Jun 9, 2015

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.

@chrisdone

This comment has been minimized.

Member

chrisdone commented Jun 9, 2015

The --verbose long-form flag is added, so marking this issue as done, and splitting off the general question of showing global options in subcommand's --help output in pcapriotti/optparse-applicative#138.

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