diff --git a/Fsdk.Tests/ArgsParsing.fs b/Fsdk.Tests/ArgsParsing.fs index 1d9ce9b..eda4f01 100644 --- a/Fsdk.Tests/ArgsParsing.fs +++ b/Fsdk.Tests/ArgsParsing.fs @@ -59,3 +59,19 @@ type ArgsParsing() = Assert.That(Seq.item 0 postFlags, Is.EqualTo "--someLongPostFlag3") Assert.That(Seq.item 1 postFlags, Is.EqualTo "-f4") | _ -> Assert.Fail "res was not ArgsParsing.BothFlags subtype" + + [] + member __.errors() = + let commandLine = "someProgramThatDoesNotMatchPredicate".Split(' ') + + let res = + Misc.ParseArgs + commandLine + (fun arg -> + arg = "someProgramArgThatDoesNotMatchProgramUsedInCommandLine" + ) + + match res with + | Misc.ArgsParsed.ErrorDetectingProgram -> Assert.Pass() + | _ -> + Assert.Fail "res was not ArgsParsing.ErrorDetectingProgram subtype" diff --git a/Fsdk/Misc.fs b/Fsdk/Misc.fs index de2b5a2..5431f46 100644 --- a/Fsdk/Misc.fs +++ b/Fsdk/Misc.fs @@ -95,6 +95,7 @@ module Misc = #endif type ArgsParsed = + | ErrorDetectingProgram | NoArgsWhatsoever | ArgWithoutFlags of string | OnlyFlags of List @@ -109,7 +110,7 @@ module Misc = (acc: ArgsParsed) : ArgsParsed = match theArgs with - | [] -> acc + | [] -> ErrorDetectingProgram | head :: tail -> if predicateToRecognizeProgram head then acc