Allow positional args to be Choice<'a, 'a> to indicate whether they came before any positional marker (#238)

This commit is contained in:
Patrick Stevens
2024-09-04 20:09:40 +01:00
committed by GitHub
parent 047b2eda99
commit 3a55ba1242
8 changed files with 374 additions and 133 deletions

View File

@@ -421,3 +421,13 @@ Required argument '--exact' received no value"""
--thing1 int32
--thing2 string
--and-another bool (positional args) (can be repeated)"""
[<Test>]
let ``Positionals are tagged with Choice`` () =
let getEnvVar (_ : string) = failwith "should not call"
ChoicePositionals.parse' getEnvVar [ "a" ; "b" ; "--" ; "--c" ; "--help" ]
|> shouldEqual
{
Args = [ Choice1Of2 "a" ; Choice1Of2 "b" ; Choice2Of2 "--c" ; Choice2Of2 "--help" ]
}

View File

@@ -4,6 +4,11 @@
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<!--
Known high severity vulnerability
I have not yet seen a single instance where I care about this warning
-->
<NoWarn>$(NoWarn),NU1903</NoWarn>
</PropertyGroup>
<ItemGroup>