@@ -37,6 +37,30 @@ module ``Argu Tests Main List`` =
3737 | Force -> " force changes in remote repo"
3838 | Remote _ -> " push changes to remote repository and branch"
3939
40+ type NewArgs =
41+ | [<Mandatory>] Name of string
42+ with
43+ interface IArgParserTemplate with
44+ member this.Usage =
45+ match this with
46+ | Name _ -> " New name"
47+
48+ type TagArgs =
49+ | New of ParseResults < NewArgs >
50+ with
51+ interface IArgParserTemplate with
52+ member this.Usage =
53+ match this with
54+ | New _ -> " New tag"
55+
56+ type CheckoutArgs =
57+ | [<Mandatory>] Branch of string
58+ with
59+ interface IArgParserTemplate with
60+ member this.Usage =
61+ match this with
62+ | Branch _ -> " push changes to remote repository and branch"
63+
4064 [<CliPrefix( CliPrefix.Dash) >]
4165 type CleanArgs =
4266 | D
@@ -94,6 +118,8 @@ module ``Argu Tests Main List`` =
94118 | [<CliPrefix( CliPrefix.Dash) >] B
95119 | [<CliPrefix( CliPrefix.Dash) >] C
96120 | [<CliPrefix( CliPrefix.None) >] Push of ParseResults < PushArgs >
121+ | [<CliPrefix( CliPrefix.None) >] Checkout of ParseResults < CheckoutArgs >
122+ | [<CliPrefix( CliPrefix.None) >] Tag of ParseResults < TagArgs >
97123 | [<CliPrefix( CliPrefix.None) >] Clean of ParseResults < CleanArgs >
98124 | [<CliPrefix( CliPrefix.None) >] Required of ParseResults < RequiredSubcommand >
99125 | [<CliPrefix( CliPrefix.None) >] Unrecognized of ParseResults < GatherUnrecognizedSubcommand >
@@ -127,6 +153,8 @@ module ``Argu Tests Main List`` =
127153 | First_ Parameter _ -> " parameter that has to appear at beginning of command line args."
128154 | Last_ Parameter _ -> " parameter that has to appear at end of command line args."
129155 | Push _ -> " push changes"
156+ | Checkout _ -> " checkout ref"
157+ | Tag _ -> " tag"
130158 | Clean _ -> " clean state"
131159 | Required _ -> " required subcommand"
132160 | Unrecognized _ -> " unrecognized subcommand"
@@ -449,6 +477,18 @@ module ``Argu Tests Main List`` =
449477 raisesWith< ArguParseException> <@ parser.ParseCommandLine args @>
450478 ( fun e -> <@ e.FirstLine.Contains " must be followed by <branch name>" @>)
451479
480+ [<Fact>]
481+ let ``Main command parsing should fail on missing mandatory sub command parameter`` () =
482+ let args = [| " --mandatory-arg" ; " true" ; " checkout" |]
483+ raisesWith< ArguParseException> <@ parser.ParseCommandLine args @>
484+ ( fun e -> <@ e.FirstLine.Contains " --branch" @>)
485+
486+ [<Fact>]
487+ let ``Main command parsing should fail on missing mandatory sub command 's sub command parameter`` () =
488+ let args = [| " --mandatory-arg" ; " true" ; " tag" ; " --new" ; |]
489+ raisesWith< ArguParseException> <@ parser.ParseCommandLine args @>
490+ ( fun e -> <@ e.FirstLine.Contains " --name" @>)
491+
452492 [<Fact>]
453493 let ``Main command parsing should allow trailing arguments`` () =
454494 let args = [| " push" ; " origin" ; " master" ; " -f" |]
@@ -616,7 +656,7 @@ module ``Argu Tests Main List`` =
616656 [<Fact>]
617657 let ``Get all subcommand parsers`` () =
618658 let subcommands = parser.GetSubCommandParsers()
619- test <@ subcommands.Length = 4 @>
659+ test <@ subcommands.Length = 6 @>
620660 test <@ subcommands |> List.forall ( fun sc -> sc.IsSubCommandParser) @>
621661
622662 [<Fact>]
0 commit comments