Ensure alternative subparsers don't carry each others contexts.

This commit is contained in:
Huw Campbell 2015-10-14 16:14:47 +11:00
parent 5b48577aa5
commit 450e7c3f70
2 changed files with 12 additions and 0 deletions

View File

@ -190,6 +190,15 @@ case_drops_back_contexts = do
i = info (p0 <**> helper) idm
checkHelpTextWith (ExitFailure 1) defaultPrefs "dropback" i ["b", "-aA"]
case_context_carry :: Assertion
case_context_carry = do
let p3 = strOption (short 'a' <> metavar "A")
p2 = subparser (command "b" (info p3 idm) <> metavar "B")
p1 = subparser (command "c" (info p3 idm) <> metavar "C")
p0 = (,) <$> p2 <*> p1
i = info (p0 <**> helper) idm
checkHelpTextWith (ExitFailure 1) defaultPrefs "carry" i ["b", "-aA", "c"]
case_many_args :: Assertion
case_many_args = do
let p = many (argument str idm)

3
tests/carry.err.txt Normal file
View File

@ -0,0 +1,3 @@
Missing: -a A
Usage: carry c -a A