Make the project a positional argument
This commit is contained in:
parent
ce48b67d13
commit
91ab968154
1 changed files with 10 additions and 7 deletions
|
|
@ -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 <path/to/project.fsproj> [--configuration Debug|Release] [--build-arg <value> ...] [--no-build] [--list | --show <id> | --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 <path/to/project.fsproj>] [--configuration Debug|Release] [--build-arg <value> ...] [--no-build] [--list | --show <id> | --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 <path/to/project.fsproj>."
|
||||
loadProjectInfo options.ProjectPath
|
||||
|
||||
let targetPathForProject (workingDirectory: string) (projectPath: string) =
|
||||
let exitCode, stdout, stderr =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue