diff --git a/docs/index.fsx b/docs/index.fsx index ae017c69..634348c4 100644 --- a/docs/index.fsx +++ b/docs/index.fsx @@ -80,7 +80,7 @@ Furthermore, you can parse environment variables, by supplying the an `Environme let argv = [| "--log-level"; "3" |] let reader = EnvironmentVariableConfigurationReader() :> IConfigurationReader -let parser = ArgumentParser.Create(programName = "rutta") +let parser = ArgumentParser.Create(programName = "rutta") // pass the reader to the Parse call let results = parser.Parse(argv, configurationReader = reader) diff --git a/tests/Argu.Tests/Tests.fs b/tests/Argu.Tests/Tests.fs index 94b3d3df..8c164c4c 100644 --- a/tests/Argu.Tests/Tests.fs +++ b/tests/Argu.Tests/Tests.fs @@ -761,6 +761,31 @@ module ``Argu Tests Main List`` = raisesWith <@ ArgumentParser.Create>() @> (fun e -> <@ e.FirstLine.Contains "generic" @>) + type NestedDuplicatesAreOk = + | [] Force + | [] Nested of ParseResults + interface IArgParserTemplate with + member _.Usage = "not tested" + and NestedSimilar = + | [] Force + interface IArgParserTemplate with + member this.Usage = "clean" + + // repro attempt for confusing "ERROR: unrecognized argument:" messages + // Actual solution: replace `dotnet toolname commandline -d ` with `dotnet tool run toolname commandline -d` + // (The `-d` was being interpreted as a switch for the `dotnet` exe) + // see https://github.com/dotnet/sdk/issues/14626 + let aliases = [| + [| "-f" ; "nested" ; "--force" |] + [| "--force" ; "nested" ; "--force" |] + [| "-f" ; "nested" ; "-f" |] + [| "-f" ; "-N" ; "-f" |] |] |> Seq.map Array.singleton + [] + let ``Nested aliased names are fine`` (args: string[]) = + let results = ArgumentParser.Create().ParseCommandLine args + test <@ results.Contains NestedDuplicatesAreOk.Force @> + let nested = results.GetResult Nested + test <@ nested.Contains Force @> [] type ArgumentSingleDash =