From 0f62865e07f4d8a31d163530e6579690fa7900a3 Mon Sep 17 00:00:00 2001 From: Eirik Tsarpalis Date: Wed, 3 Jan 2018 21:47:21 +0000 Subject: [PATCH] use ReflectedDefinitionAttribute for quotation-based query APIs --- docs/content/tutorial.fsx | 8 +++---- paket.dependencies | 2 +- paket.lock | 18 +++++++++------- samples/Argu.Samples.LS/Program.fs | 2 +- src/Argu/Argu.fsproj | 1 + src/Argu/ArgumentParser.fs | 4 ++-- src/Argu/ParseResults.fs | 26 +++++++++++------------ tests/Argu.Tests/Tests.fs | 34 +++++++++++++++--------------- 8 files changed, 49 insertions(+), 46 deletions(-) diff --git a/docs/content/tutorial.fsx b/docs/content/tutorial.fsx index 5eec812c..86e7ba1f 100644 --- a/docs/content/tutorial.fsx +++ b/docs/content/tutorial.fsx @@ -126,13 +126,13 @@ it is more likely that you need to query the results for specific parameters: *) -let detach = results.Contains <@ Detach @> -let listener = results.GetResults <@ Listener @> +let detach = results.Contains Detach +let listener = results.GetResults Listener (** The following methods return the last observed result for given argument case *) -let dataOpt = results.TryGetResult <@ Data @> -let logLevel = results.GetResult (<@ Log_Level @>, defaultValue = 0) +let dataOpt = results.TryGetResult Data +let logLevel = results.GetResult (Log_Level, defaultValue = 0) (** diff --git a/paket.dependencies b/paket.dependencies index 998ee878..330550e5 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -16,7 +16,7 @@ group Legacy source https://www.nuget.org/api/v2 redirects: force - nuget FSharp.Core >= 3.1 lowest_matching:true + nuget FSharp.Core >= 4.0 lowest_matching:true group Build framework: net461 diff --git a/paket.lock b/paket.lock index e6c5eb2f..06b3d388 100644 --- a/paket.lock +++ b/paket.lock @@ -2,10 +2,11 @@ REDIRECTS: FORCE RESTRICTION: || (== net40) (== net461) (== netcoreapp2.0) (== netstandard2.0) NUGET remote: https://www.nuget.org/api/v2 - FsCheck (3.0.0-alpha2) - FSharp.Core (>= 4.1) - restriction: || (== net40) (== net461) (&& (== netcoreapp2.0) (< netstandard1.6)) (&& (== netstandard2.0) (< netstandard1.6)) - FSharp.Core (>= 4.1.18) - restriction: || (&& (== net40) (>= netstandard1.6)) (&& (== net461) (>= netstandard1.6)) (== netcoreapp2.0) (== netstandard2.0) - NETStandard.Library (>= 1.6.1) - restriction: || (&& (== net40) (>= netstandard1.6)) (&& (== net461) (>= netstandard1.6)) (== netcoreapp2.0) (== netstandard2.0) + FsCheck (3.0.0-alpha3) + FSharp.Core (>= 4.0.0.1) - restriction: || (&& (== net40) (>= net452)) (== net461) (&& (== netcoreapp2.0) (>= net452)) (&& (== netstandard2.0) (>= net452)) + FSharp.Core (>= 4.2.3) - restriction: || (&& (== net40) (>= netstandard1.6)) (&& (== net461) (< net452) (>= netstandard1.6)) (== netcoreapp2.0) (== netstandard2.0) + NETStandard.Library (>= 1.6.1) - restriction: || (&& (== net40) (>= netstandard1.6)) (&& (== net461) (< net452) (>= netstandard1.6)) (== netcoreapp2.0) (== netstandard2.0) + System.ValueTuple (>= 4.4) - restriction: || (&& (== net40) (>= netstandard1.6)) (&& (== net461) (< net452) (>= netstandard1.6)) (== netcoreapp2.0) (== netstandard2.0) FSharp.Core (4.2.3) System.Collections (>= 4.0.11) - restriction: || (&& (== net40) (>= netstandard1.6)) (&& (== net461) (< net45) (>= netstandard1.6)) (== netcoreapp2.0) (== netstandard2.0) System.Console (>= 4.0) - restriction: || (&& (== net40) (>= netstandard1.6)) (&& (== net461) (< net45) (>= netstandard1.6)) (== netcoreapp2.0) (== netstandard2.0) @@ -50,7 +51,7 @@ NUGET Microsoft.NET.Test.Sdk (15.5.0) - version_in_path: true, restriction: || (&& (== net40) (>= netcoreapp1.0)) (&& (== net461) (>= netcoreapp1.0)) (== netcoreapp2.0) (&& (== netstandard2.0) (>= netcoreapp1.0)) Microsoft.CodeCoverage (>= 1.0.3) Microsoft.TestPlatform.TestHost (>= 15.5) - Microsoft.NETCore.Platforms (2.0.1) - restriction: || (&& (== net40) (>= monotouch)) (&& (== net40) (>= netcoreapp2.0)) (&& (== net40) (>= netstandard1.6)) (&& (== net40) (>= netstandard2.0)) (&& (== net40) (>= xamarinios)) (&& (== net40) (>= xamarinmac)) (&& (== net40) (>= xamarintvos)) (&& (== net40) (>= xamarinwatchos)) (&& (== net461) (>= monotouch)) (&& (== net461) (< net45) (>= netstandard2.0)) (&& (== net461) (>= netcoreapp2.0)) (&& (== net461) (>= netstandard1.6)) (&& (== net461) (>= xamarinios)) (&& (== net461) (>= xamarinmac)) (&& (== net461) (>= xamarintvos)) (&& (== net461) (>= xamarinwatchos)) (== netcoreapp2.0) (== netstandard2.0) + Microsoft.NETCore.Platforms (2.0.1) - restriction: || (&& (== net40) (>= monotouch)) (&& (== net40) (>= netcoreapp2.0)) (&& (== net40) (>= netstandard1.6)) (&& (== net40) (>= netstandard2.0)) (&& (== net40) (>= xamarinios)) (&& (== net40) (>= xamarinmac)) (&& (== net40) (>= xamarintvos)) (&& (== net40) (>= xamarinwatchos)) (&& (== net461) (>= monotouch)) (&& (== net461) (< net45) (>= netstandard1.6)) (&& (== net461) (< net45) (>= netstandard2.0)) (&& (== net461) (< net452) (>= netstandard1.6)) (&& (== net461) (>= netcoreapp2.0)) (&& (== net461) (< netstandard1.0) (>= netstandard1.6)) (&& (== net461) (< netstandard1.1) (>= netstandard1.6)) (&& (== net461) (< netstandard1.3) (>= netstandard1.6) (>= wpa81)) (&& (== net461) (>= netstandard1.6) (< portable-net45+win8+wp8+wpa81)) (&& (== net461) (>= netstandard1.6) (< portable-net45+win8+wpa81)) (&& (== net461) (>= netstandard1.6) (< portable-net451+win81+wpa81)) (&& (== net461) (>= netstandard1.6) (>= uap10.0)) (&& (== net461) (>= xamarinios)) (&& (== net461) (>= xamarinmac)) (&& (== net461) (>= xamarintvos)) (&& (== net461) (>= xamarinwatchos)) (== netcoreapp2.0) (== netstandard2.0) Microsoft.NETCore.Targets (2.0) - restriction: || (&& (== net40) (>= netcoreapp1.0)) (&& (== net40) (>= netstandard1.6)) (&& (== net461) (< net45) (>= netstandard1.6)) (&& (== net461) (>= netcoreapp1.0)) (&& (== net461) (< netstandard1.1) (>= netstandard1.6)) (&& (== net461) (>= netstandard1.6) (< portable-net45+win8+wp8+wpa81)) (&& (== net461) (>= netstandard1.6) (< portable-net45+win8+wpa81)) (== netcoreapp2.0) (== netstandard2.0) Microsoft.TestPlatform.ObjectModel (15.5.0) - version_in_path: true, restriction: || (&& (== net40) (>= netcoreapp1.0)) (&& (== net461) (>= netcoreapp1.0)) (== netcoreapp2.0) (&& (== netstandard2.0) (>= netcoreapp1.0)) NETStandard.Library (>= 1.6) - restriction: || (&& (== net40) (>= netstandard1.5)) (&& (== net461) (< net451) (>= netstandard1.5)) (== netcoreapp2.0) (== netstandard2.0) @@ -79,7 +80,7 @@ NUGET Microsoft.NETCore.Platforms (>= 2.0) - restriction: || (&& (== net40) (>= netcoreapp2.0)) (&& (== net461) (>= netcoreapp2.0)) (== netcoreapp2.0) (&& (== netstandard2.0) (>= netcoreapp2.0)) System.Security.AccessControl (>= 4.4) - restriction: || (&& (== net40) (>= monoandroid)) (&& (== net40) (>= monotouch)) (&& (== net40) (>= net461)) (&& (== net40) (>= netcoreapp2.0)) (&& (== net40) (>= netstandard2.0)) (&& (== net40) (>= xamarinios)) (&& (== net40) (>= xamarinmac)) (&& (== net40) (>= xamarintvos)) (&& (== net40) (>= xamarinwatchos)) (== net461) (== netcoreapp2.0) (== netstandard2.0) System.Security.Principal.Windows (>= 4.4) - restriction: || (&& (== net40) (>= monoandroid)) (&& (== net40) (>= monotouch)) (&& (== net40) (>= net461)) (&& (== net40) (>= netcoreapp2.0)) (&& (== net40) (>= netstandard2.0)) (&& (== net40) (>= xamarinios)) (&& (== net40) (>= xamarinmac)) (&& (== net40) (>= xamarintvos)) (&& (== net40) (>= xamarinwatchos)) (== net461) (== netcoreapp2.0) (== netstandard2.0) - NETStandard.Library (2.0.1) - restriction: || (&& (== net40) (== net461)) (&& (== net40) (>= netcoreapp1.0)) (&& (== net40) (>= netstandard1.1)) (&& (== net40) (>= netstandard1.6)) (&& (== net461) (< net452)) (&& (== net461) (>= netcoreapp1.0)) (&& (== net461) (>= netstandard1.6)) (== netcoreapp2.0) (== netstandard2.0) + NETStandard.Library (2.0.1) - restriction: || (&& (== net40) (== net461)) (&& (== net40) (>= netcoreapp1.0)) (&& (== net40) (>= netstandard1.1)) (&& (== net40) (>= netstandard1.6)) (&& (== net461) (< net452)) (&& (== net461) (>= netcoreapp1.0)) (== netcoreapp2.0) (== netstandard2.0) Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (== net40) (>= monoandroid)) (&& (== net40) (>= monotouch)) (&& (== net40) (>= net45)) (&& (== net40) (>= net451)) (&& (== net40) (>= net46)) (&& (== net40) (>= net461)) (&& (== net40) (>= netcoreapp2.0)) (&& (== net40) (>= netstandard1.0)) (&& (== net40) (>= netstandard1.1)) (&& (== net40) (>= netstandard1.2)) (&& (== net40) (>= netstandard1.3)) (&& (== net40) (>= netstandard1.4)) (&& (== net40) (>= netstandard1.5)) (&& (== net40) (>= netstandard1.6)) (&& (== net40) (>= netstandard2.0)) (&& (== net40) (>= portable-net45+win8+wp8+wpa81)) (&& (== net40) (>= portable-net45+win8+wpa81)) (&& (== net40) (>= portable-net451+win81+wpa81)) (&& (== net40) (>= uap10.0)) (&& (== net40) (>= wpa81)) (&& (== net40) (>= xamarinios)) (&& (== net40) (>= xamarinmac)) (&& (== net40) (>= xamarintvos)) (&& (== net40) (>= xamarinwatchos)) (== net461) (== netcoreapp2.0) (== netstandard2.0) Newtonsoft.Json (10.0.3) - version_in_path: true, restriction: || (&& (== net40) (>= netcoreapp1.0)) (&& (== net461) (>= netcoreapp1.0)) (== netcoreapp2.0) (&& (== netstandard2.0) (>= netcoreapp1.0)) Microsoft.CSharp (>= 4.3) - restriction: || (&& (== net40) (< net20) (>= netstandard1.0)) (&& (== net40) (< net20) (>= netstandard1.3)) (&& (== net461) (< net20)) (== netcoreapp2.0) (== netstandard2.0) @@ -622,6 +623,7 @@ NUGET Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (== net40) (&& (== net461) (< net451)) (&& (== net461) (< portable-net451+win81+wpa81)) (== netcoreapp2.0) (== netstandard2.0) Microsoft.NETCore.Targets (>= 1.1) - restriction: || (== net40) (&& (== net461) (< net451)) (&& (== net461) (< portable-net451+win81+wpa81)) (== netcoreapp2.0) (== netstandard2.0) System.Runtime (>= 4.3) - restriction: || (== net40) (&& (== net461) (< net451)) (&& (== net461) (< portable-net451+win81+wpa81)) (== netcoreapp2.0) (== netstandard2.0) + System.ValueTuple (4.4) - restriction: || (&& (== net40) (>= netstandard1.6)) (&& (== net461) (< net452) (>= netstandard1.6)) (== netcoreapp2.0) (== netstandard2.0) System.Xml.ReaderWriter (4.3.0) - version_in_path: true, restriction: || (&& (== net40) (>= netcoreapp1.0)) (&& (== net461) (>= netcoreapp1.0)) (== netcoreapp2.0) (&& (== netstandard2.0) (>= netcoreapp1.0)) System.Collections (>= 4.3) - restriction: || (== net40) (&& (== net461) (< net45)) (&& (== net461) (< portable-net45+win8+wp8+wpa81)) (== netcoreapp2.0) (== netstandard2.0) System.Diagnostics.Debug (>= 4.3) - restriction: || (== net40) (&& (== net461) (< net45)) (&& (== net461) (< portable-net45+win8+wp8+wpa81)) (== netcoreapp2.0) (== netstandard2.0) @@ -739,14 +741,14 @@ NUGET xunit.runner.console (2.3.1) GITHUB remote: fsharp/FAKE - modules/Octokit/Octokit.fsx (642a01a5e17b870f816cdd7ee09115e018b786f0) + modules/Octokit/Octokit.fsx (51a7cae12acc7292db4623ae0e3cc3a2ce6ca1c9) Octokit (>= 0.20) GROUP Legacy REDIRECTS: FORCE RESTRICTION: == net40 NUGET remote: https://www.nuget.org/api/v2 - FSharp.Core (3.1.2) + FSharp.Core (4.0.0.1) GROUP SourceLink STORAGE: NONE diff --git a/samples/Argu.Samples.LS/Program.fs b/samples/Argu.Samples.LS/Program.fs index a63ea72b..0b73d320 100644 --- a/samples/Argu.Samples.LS/Program.fs +++ b/samples/Argu.Samples.LS/Program.fs @@ -11,7 +11,7 @@ let main argv = let results = parser.ParseCommandLine argv printfn "Got parse results %A" <| results.GetAllResults() - let files = results.GetResult(<@ Files @>, defaultValue = []) + let files = results.GetResult(Files, defaultValue = []) printfn "Listing files %A" files 0 \ No newline at end of file diff --git a/src/Argu/Argu.fsproj b/src/Argu/Argu.fsproj index d679854e..ad165c69 100644 --- a/src/Argu/Argu.fsproj +++ b/src/Argu/Argu.fsproj @@ -8,6 +8,7 @@ false ..\..\bin\Debug\ ..\..\bin\Debug\net40\Argu.XML + AnyCPU RELEASE diff --git a/src/Argu/ArgumentParser.fs b/src/Argu/ArgumentParser.fs index a8c55882..4e621a40 100644 --- a/src/Argu/ArgumentParser.fs +++ b/src/Argu/ArgumentParser.fs @@ -181,7 +181,7 @@ and [] /// Gets a subparser associated with specific subcommand instance /// /// Expression providing the subcommand union constructor. - member __.GetSubCommandParser (expr : Expr -> 'Template>) : ArgumentParser<'SubTemplate> = + member __.GetSubCommandParser ([] expr : Expr -> 'Template>) : ArgumentParser<'SubTemplate> = let uci = expr2Uci expr let case = argInfo.Cases.[uci.Tag] match case.ParameterInfo with @@ -208,7 +208,7 @@ and [] /// Gets argument metadata for given union case constructor /// /// Quoted union case constructor. - member __.GetArgumentCaseInfo(ctorExpr : Expr<'Fields -> 'Template>) : ArgumentCaseInfo = + member __.GetArgumentCaseInfo([] ctorExpr : Expr<'Fields -> 'Template>) : ArgumentCaseInfo = let uci = expr2Uci ctorExpr argInfo.Cases.[uci.Tag].ToArgumentCaseInfo() diff --git a/src/Argu/ParseResults.fs b/src/Argu/ParseResults.fs index b6addf31..2d8f6869 100644 --- a/src/Argu/ParseResults.fs +++ b/src/Argu/ParseResults.fs @@ -61,13 +61,13 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// Query parse results for parameterless argument. /// The name of the parameter, expressed as quotation of DU constructor. /// Optional source restriction: AppSettings or CommandLine. - member __.GetResults (expr : Expr<'Template>, ?source : ParseSource) : 'Template list = + member __.GetResults ([] expr : Expr<'Template>, ?source : ParseSource) : 'Template list = expr |> getResults source |> Seq.map (fun r -> r.Value :?> 'Template) |> Seq.toList /// Query parse results for argument with parameters. /// The name of the parameter, expressed as quotation of DU constructor. /// Optional source restriction: AppSettings or CommandLine. - member __.GetResults (expr : Expr<'Fields -> 'Template>, ?source : ParseSource) : 'Fields list = + member __.GetResults ([] expr : Expr<'Fields -> 'Template>, ?source : ParseSource) : 'Fields list = expr |> getResults source |> Seq.map (fun r -> r.FieldContents :?> 'Fields) |> Seq.toList /// Gets all parse results. @@ -84,14 +84,14 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// Command line parameters have precedence over AppSettings parameters. /// The name of the parameter, expressed as quotation of DU constructor. /// Optional source restriction: AppSettings or CommandLine. - member __.TryGetResult (expr : Expr<'Template>, ?source : ParseSource) : 'Template option = + member __.TryGetResult ([] expr : Expr<'Template>, ?source : ParseSource) : 'Template option = expr |> tryGetResult source |> Option.map (fun r -> r.Value :?> 'Template) /// Returns the *last* specified parameter of given type, if it exists. /// Command line parameters have precedence over AppSettings parameters. /// The name of the parameter, expressed as quotation of DU constructor. /// Optional source restriction: AppSettings or CommandLine. - member __.TryGetResult (expr : Expr<'Fields -> 'Template>, ?source : ParseSource) : 'Fields option = + member __.TryGetResult ([] expr : Expr<'Fields -> 'Template>, ?source : ParseSource) : 'Fields option = expr |> tryGetResult source |> Option.map (fun r -> r.FieldContents :?> 'Fields) /// Returns the *last* specified parameter of given type. @@ -99,7 +99,7 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// The name of the parameter, expressed as quotation of DU constructor. /// Return this of no parameter of specific kind has been specified. /// Optional source restriction: AppSettings or CommandLine. - member s.GetResult (expr : Expr<'Template>, ?defaultValue : 'Template, ?source : ParseSource) : 'Template = + member s.GetResult ([] expr : Expr<'Template>, ?defaultValue : 'Template, ?source : ParseSource) : 'Template = match defaultValue with | None -> let r = getResult source expr in r.Value :?> 'Template | Some def -> defaultArg (s.TryGetResult(expr, ?source = source)) def @@ -109,7 +109,7 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// The name of the parameter, expressed as quotation of DU constructor. /// Return this of no parameter of specific kind has been specified. /// Optional source restriction: AppSettings or CommandLine. - member s.GetResult (expr : Expr<'Fields -> 'Template>, ?defaultValue : 'Fields , ?source : ParseSource) : 'Fields = + member s.GetResult ([] expr : Expr<'Fields -> 'Template>, ?defaultValue : 'Fields , ?source : ParseSource) : 'Fields = match defaultValue with | None -> let r = getResult source expr in r.FieldContents :?> 'Fields | Some def -> defaultArg (s.TryGetResult expr) def @@ -117,11 +117,11 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// Checks if parameter of specific kind has been specified. /// The name of the parameter, expressed as quotation of DU constructor. /// Optional source restriction: AppSettings or CommandLine. - member __.Contains (expr : Expr<'Template>, ?source : ParseSource) : bool = containsResult source expr + member __.Contains ([] expr : Expr<'Template>, ?source : ParseSource) : bool = containsResult source expr /// Checks if parameter of specific kind has been specified. /// The name of the parameter, expressed as quotation of DU constructor. /// Optional source restriction: AppSettings or CommandLine. - member __.Contains (expr : Expr<'Fields -> 'Template>, ?source : ParseSource) : bool = containsResult source expr + member __.Contains ([] expr : Expr<'Fields -> 'Template>, ?source : ParseSource) : bool = containsResult source expr /// Raise an error through the argument parser's exiter mechanism. Display usage optionally. /// The error message to be displayed. @@ -153,7 +153,7 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// The name of the parameter, expressed as quotation of DU constructor. /// The post-processing parser. /// Optional source restriction: AppSettings or CommandLine. - member r.PostProcessResult (expr : Expr<'Field -> 'Template>, parser : 'Field -> 'R, ?source) : 'R = + member r.PostProcessResult ([] expr : Expr<'Field -> 'Template>, parser : 'Field -> 'R, ?source) : 'R = expr |> getResult source |> parseResult parser /// Query parse results for given argument kind. @@ -163,7 +163,7 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// The name of the parameter, expressed as quotation of DU constructor. /// The post-processing parser. /// Optional source restriction: AppSettings or CommandLine. - member r.PostProcessResults (expr : Expr<'Field -> 'Template>, parser : 'Field -> 'R, ?source) : 'R list = + member r.PostProcessResults ([] expr : Expr<'Field -> 'Template>, parser : 'Field -> 'R, ?source) : 'R list = expr |> getResults source |> Seq.map (parseResult parser) |> Seq.toList /// Returns the *last* specified parameter of given type. @@ -173,7 +173,7 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// The name of the parameter, expressed as quotation of DU constructor. /// The post-processing parser. /// Optional source restriction: AppSettings or CommandLine. - member r.TryPostProcessResult (expr : Expr<'Field -> 'Template>, parser : 'Field -> 'R, ?source) : 'R option = + member r.TryPostProcessResult ([] expr : Expr<'Field -> 'Template>, parser : 'Field -> 'R, ?source) : 'R option = expr |> tryGetResult source |> Option.map (parseResult parser) /// @@ -184,7 +184,7 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// The name of the parameter, expressed as quotation of DU constructor. /// The iterator body. /// Option source restriction: AppSettings or CommandLine. - member r.IterResults (expr : Expr<'Field -> 'Template>, iterator : 'Field -> unit, ?source) : unit = + member r.IterResults ([] expr : Expr<'Field -> 'Template>, iterator : 'Field -> unit, ?source) : unit = expr |> getResults source |> Seq.iter (parseResult iterator) /// @@ -195,7 +195,7 @@ type ParseResults<'Template when 'Template :> IArgParserTemplate> /// The name of the parameter, expressed as quotation of DU constructor. /// The iterator body. /// Option source restriction: AppSettings or CommandLine. - member r.IterResult (expr : Expr<'Field -> 'Template>, iterator : 'Field -> unit, ?source) : unit = + member r.IterResult ([] expr : Expr<'Field -> 'Template>, iterator : 'Field -> unit, ?source) : unit = expr |> tryGetResult source |> Option.iter (parseResult iterator) /// diff --git a/tests/Argu.Tests/Tests.fs b/tests/Argu.Tests/Tests.fs index 610d8718..9ca51f19 100644 --- a/tests/Argu.Tests/Tests.fs +++ b/tests/Argu.Tests/Tests.fs @@ -156,39 +156,39 @@ module ``Argu Tests`` = [] let ``AppSettings CSV parsing`` () = let results = parseFunc true (function "rest arg" -> Some("1,2,3,4,5") | _ -> None) - test <@ results.GetResults <@ Rest_Arg @> = [1 .. 5] @> + test <@ results.GetResults Rest_Arg = [1 .. 5] @> [] let ``AppSettings Flag parsing`` () = let results = parseFunc true (function "a" -> Some("true") | "b" -> Some("false") | _ -> None) - test <@ results.Contains <@ A @> @> - test <@ results.Contains <@ B @> |> not @> - test <@ results.Contains <@ C @> |> not @> + test <@ results.Contains A @> + test <@ results.Contains B |> not @> + test <@ results.Contains C |> not @> [] let ``AppSettings multi-parameter parsing 1`` () = let results = parseFunc true (function "env" -> Some("key,value") | _ -> None) - test <@ results.GetResult <@ Env @> = ("key", "value") @> + test <@ results.GetResult Env = ("key", "value") @> [] let ``AppSettings multi-parameter parsing 2`` () = let results = parseFunc true (function "listener" -> Some("localhost:80") | _ -> None) - test <@ results.GetResult <@ Listener @> = ("localhost", 80) @> + test <@ results.GetResult Listener = ("localhost", 80) @> [] let ``AppSettings Optional param`` () = let results = parseFunc true (function "optional" -> Some "42" | _ -> None) - test <@ results.GetResult <@ Optional @> = (Some 42) @> + test <@ results.GetResult Optional = (Some 42) @> [] let ``AppSettings List param populated`` () = let results = parseFunc true (function "list" -> Some "1,2,3,4,5" | _ -> None) - test <@ results.GetResult <@ List @> = [1 .. 5] @> + test <@ results.GetResult List = [1 .. 5] @> [] let ``AppSettings List param single`` () = let results = parseFunc true (function "list" -> Some "42" | _ -> None) - test <@ results.GetResult <@ List @> = [42] @> + test <@ results.GetResult List = [42] @> [] @@ -221,7 +221,7 @@ module ``Argu Tests`` = let ``Rest Parameter`` () = let args = [|1..100|] |> Array.map string |> Array.append [| "--mandatory-arg" ; "true" ; "--rest-arg" |] let result = parser.ParseCommandLine args - test <@ result.GetResults <@ Rest_Arg @> = [1..100] @> + test <@ result.GetResults Rest_Arg = [1..100] @> [] let ``Multiple AltCommandLine`` () = @@ -239,7 +239,7 @@ module ``Argu Tests`` = let bytes = [|1uy .. 255uy|] let args = parser.PrintCommandLineArguments [ Mandatory_Arg false ; Data(42, bytes) ] let results = parser.ParseCommandLine args - test <@ let _,bytes' = results.GetResult <@ Data @> in bytes' = bytes @> + test <@ let _,bytes' = results.GetResult Data in bytes' = bytes @> [] let ``Parse colon assignment 1`` () = @@ -259,7 +259,7 @@ module ``Argu Tests`` = let arg = [ Env("foo", "bar") ] let clp = parser.PrintCommandLineArguments arg let result = parser.Parse(clp, ignoreMissing = true) - test <@ result.GetResult <@ Env @> = ("foo", "bar") @> + test <@ result.GetResult Env = ("foo", "bar") @> [] let ``Parse key-value equals assignment 2`` () = @@ -269,12 +269,12 @@ module ``Argu Tests`` = [] let ``Parse equals assignment`` () = let result = parser.Parse([|"--dir=../../my-relative-path"|], ignoreMissing = true) - test <@ result.GetResult <@ Dir @> = "../../my-relative-path" @> + test <@ result.GetResult Dir = "../../my-relative-path" @> [] let ``Parse equals assignment 2`` () = let result = parser.Parse([|"--dir==foo"|], ignoreMissing = true) - test <@ result.GetResult <@ Dir @> = "=foo" @> + test <@ result.GetResult Dir = "=foo" @> [] let ``Should fail on incorrect assignment 1`` () = @@ -293,7 +293,7 @@ module ``Argu Tests`` = test <@ results.Contains <@ Detach @> @> test <@ results.GetResult <@ Listener @> = ("localhost", 8080) @> - test <@ results.GetResults <@ Log_Level @> = [2] @> + test <@ results.GetResults Log_Level = [2] @> test <@ results.PostProcessResult (<@ Log_Level @>, fun x -> x + 1) = 3 @> [] @@ -327,7 +327,7 @@ module ``Argu Tests`` = let ``Simple subcommand parsing 2`` () = let args = [|"clean"; "-fdx"|] let results = parser.ParseCommandLine(args, ignoreMissing = true) - let nested = results.GetResult <@ Clean @> + let nested = results.GetResult Clean test <@ match results.TryGetSubCommand() with Some (Clean _) -> true | _ -> false @> test <@ nested.GetAllResults() = [F; D; X] @> @@ -361,7 +361,7 @@ module ``Argu Tests`` = let ``Main command taking list of arguments`` () = let args = [|"--mandatory-arg" ; "true" ; "a" ; "b" ; "c" ; "ff" ; "d" |] let results = parser.ParseCommandLine(args, ignoreUnrecognized = true) - test <@ results.GetResult <@ Main @> = ['a' ; 'b' ; 'c'] @> + test <@ results.GetResult Main = ['a' ; 'b' ; 'c'] @> [] let ``SubParsers should correctly handle inherited params`` () =