Skip to content

Commit

Permalink
Add documentation on 'noBacktrack' preference
Browse files Browse the repository at this point in the history
Subcommand parsers are often disjoint, meaning that if one fails
to parse after the command name then all others (having distinct
command names) will also fail to parse. When the 'noBacktrack'
preference is not set but 'showHelpOnError' is this leads to
the help for the top-level parser being shown instead of the
help for the failing subcommand.

A note has been added to the Haddock docs for the 'noBacktrack'
option to make this clear.
  • Loading branch information
Sean Seefried committed Apr 30, 2018
1 parent 72ae4b6 commit 08edd73
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Options/Applicative/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@ showHelpOnEmpty :: PrefsMod
showHelpOnEmpty = PrefsMod $ \p -> p { prefShowHelpOnEmpty = True }

-- | Turn off backtracking after subcommand is parsed.
--
-- When used in conjunction with 'showHelpOnError' and a parser
-- with subcommands it will cause the program, on error, to show
-- the help for the subcommand instead of backtracking to the
-- parent parser and trying to find an alternate parse there.
noBacktrack :: PrefsMod
noBacktrack = PrefsMod $ \p -> p { prefBacktrack = False }

Expand Down

0 comments on commit 08edd73

Please sign in to comment.