Skip to content

Commit 49bf07c

Browse files
committed
Fix #809 Use showHelpOnEmpty
For example, before the change, `stack ls` yields only: ~~~ Missing: COMMAND Usage: stack.exe ls COMMAND [--setup-info-yaml URL] [--snapshot-location-base URL] [--help] List command. (Supports snapshots, dependencies and stack's styles) ~~~ After the change, `stack ls` yields the more informative: ~~~ Usage: stack.exe ls COMMAND [--setup-info-yaml URL] [--snapshot-location-base URL] [--help] List command. (Supports snapshots, dependencies and stack's styles) Available options: --setup-info-yaml URL Alternate URL or relative / absolute path for stack dependencies --snapshot-location-base URL The base location of LTS/Nightly snapshots --help Show this help text Available commands: snapshots View local snapshot (default option) dependencies View the dependencies stack-colors View stack's output styles stack-colours View stack's output styles (alias for 'stack-colors') Run 'stack --help' for global options that apply to all subcommands. ~~~ Also deletes the case: ~~~haskell Failure _ | null args -> withArgs ["--help"] (execParser parser) ~~~ as `stack` (without more) is now handled without it. Also updates `ChangeLog.md`. Tested by building and using Stack, including using Stack with scripts and `stack script`.
1 parent e14a2b7 commit 49bf07c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Other enhancements:
2929
comment in `Script.hs` on the command line. That may help test that scripts
3030
compile in CI (continuous integration). See
3131
[#5755](https://github.com/commercialhaskell/stack/issues/5755)
32+
* Fuller help is provided at the command line if a subcommand is missing (for
33+
example, `stack ls` now yields the equivalent of `stack ls --help`). See
34+
[#809](https://github.com/commercialhaskell/stack/issues/809)
3235

3336
Bug fixes:
3437

src/Options/Applicative/Complicated.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ complicatedOptions
4848
-> IO (a,b)
4949
complicatedOptions numericVersion stringVersion numericHpackVersion h pd footerStr commonParser mOnFailure commandParser =
5050
do args <- getArgs
51-
(a,(b,c)) <- case execParserPure (prefs noBacktrack) parser args of
52-
Failure _ | null args -> withArgs ["--help"] (execParser parser)
51+
(a,(b,c)) <- let parserPrefs = prefs $ noBacktrack <> showHelpOnEmpty
52+
in case execParserPure parserPrefs parser args of
5353
-- call onFailure handler if it's present and parsing options failed
5454
Failure f | Just onFailure <- mOnFailure -> onFailure f args
5555
parseResult -> handleParseResult parseResult

0 commit comments

Comments
 (0)