Skip to content

Commit

Permalink
Merge pull request #403 from pcapriotti/topic/internal-multi
Browse files Browse the repository at this point in the history
Topic/internal multi
  • Loading branch information
HuwCampbell authored Jul 31, 2020
2 parents ef7c1d8 + 997bc2b commit 9cc0947
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Options/Applicative/Help/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ foldTree prefs s (AltNode b xs) =
foldTree prefs s (BindNode x) =
let rendered =
wrapOver NoDefault NeverRequired (foldTree prefs s x)
withPrefix =
rendered <> stringChunk (prefMultiSuffix prefs)
in (withPrefix, NeverRequired)

-- We always want to display the rendered option
-- if it exists, and only attach the suffix then.
withSuffix =
rendered >>= (\r -> pure r <> stringChunk (prefMultiSuffix prefs))
in (withSuffix, NeverRequired)

-- | Generate a full help text for a parser
fullDesc :: ParserPrefs -> Parser a -> Chunk Doc
Expand Down
7 changes: 7 additions & 0 deletions tests/test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,13 @@ prop_grouped_many_dual_flag_ellipsis = once $
r = show . extractChunk $ H.briefDesc p (x *> many x)
in r === "(-a|-b) [-a|-b]..."

prop_issue_402 :: Property
prop_issue_402 = once $
let x = some (flag' () (short 'a')) <|> some (flag' () (short 'b' <> internal))
p = prefs (multiSuffix "...")
r = show . extractChunk $ H.briefDesc p x
in r === "(-a)..."

prop_nice_some1 :: Property
prop_nice_some1 = once $
let x = Options.Applicative.NonEmpty.some1 (flag' () (short 'a'))
Expand Down

0 comments on commit 9cc0947

Please sign in to comment.