diff --git a/verify-coverage-mutants.fsx b/verify-coverage-mutants.fsx index 81e9b3c..0c68461 100755 --- a/verify-coverage-mutants.fsx +++ b/verify-coverage-mutants.fsx @@ -25,7 +25,7 @@ type Command = type Options = { Configuration: string - ProjectPath: string option + ProjectPath: string BuildArgs: string list NoBuild: bool Command: Command } @@ -79,19 +79,24 @@ let repoRoot = stdout.Trim() let parseArgs (args: string list) = + let usage () = + fail "Usage: verify-coverage-mutants.fsx [--configuration Debug|Release] [--build-arg ...] [--no-build] [--list | --show | --run [id...]]" + let rec loop configuration projectPath buildArgs noBuild remaining = match remaining with | [] -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = Run [] } | "--configuration" :: value :: tail -> loop value projectPath buildArgs noBuild tail - | "--project" :: value :: tail -> loop configuration (Some value) buildArgs noBuild tail | "--build-arg" :: value :: tail -> loop configuration projectPath (value :: buildArgs) noBuild tail | "--no-build" :: tail -> loop configuration projectPath buildArgs true tail | "--list" :: tail when tail.IsEmpty -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = List } | "--show" :: id :: tail when tail.IsEmpty -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = Show id } | "--run" :: tail -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = Run tail } | value :: tail when not (value.StartsWith "--") -> { Configuration = configuration; ProjectPath = projectPath; BuildArgs = List.rev buildArgs; NoBuild = noBuild; Command = Run (value :: tail) } - | _ -> fail "Usage: dotnet fsi verify-coverage-mutants.fsx [--project ] [--configuration Debug|Release] [--build-arg ...] [--no-build] [--list | --show | --run [id...]]" - loop "Debug" None [] false args + | _ -> usage () + + match args with + | projectPath :: tail when not (projectPath.StartsWith "--") -> loop "Debug" projectPath [] false tail + | _ -> usage () let options = parseArgs (fsi.CommandLineArgs |> Array.skip 1 |> Array.toList) @@ -114,9 +119,7 @@ let loadProjectInfo (projectPath: string) = AbsoluteProjectPath = absoluteProjectPath } let project = - match options.ProjectPath with - | Some projectPath -> loadProjectInfo projectPath - | None -> fail "Missing required --project ." + loadProjectInfo options.ProjectPath let targetPathForProject (workingDirectory: string) (projectPath: string) = let exitCode, stdout, stderr =