From 294b2f85a962bcecc31c140aa17f280d7bef4088 Mon Sep 17 00:00:00 2001 From: Sven van Heugten Date: Tue, 12 May 2026 16:24:19 +0200 Subject: [PATCH] Add Argu for argument parsing --- Mutannot/Mutannot.fsproj | 1 + Mutannot/Program.fs | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Mutannot/Mutannot.fsproj b/Mutannot/Mutannot.fsproj index 7c6381b..396d322 100644 --- a/Mutannot/Mutannot.fsproj +++ b/Mutannot/Mutannot.fsproj @@ -11,6 +11,7 @@ + diff --git a/Mutannot/Program.fs b/Mutannot/Program.fs index 15ba0f2..0153b3f 100644 --- a/Mutannot/Program.fs +++ b/Mutannot/Program.fs @@ -3,6 +3,7 @@ open System.IO open System.Reflection open System.Runtime.InteropServices open Fli +open Argu type MutationCase = { TestName: string; Patch: string } @@ -118,18 +119,26 @@ let getMutationCases projectPath = | _ -> None)) |> Seq.toList +type Arguments = + | [] ProjectPath of ProjectPath: string + + interface IArgParserTemplate with + member s.Usage = + match s with + | ProjectPath _ -> "path/to/project.csproj|fsproj" + [] let main argv = - if argv.Length <> 1 then - eprintf "Usage: mutannot \n" - exit 1 + let parsedArguments = + ArgumentParser.Create(programName = "mutannot") + |> _.ParseCommandLine(argv) + + let projectPath = parsedArguments.GetResult ProjectPath ensureCleanWorkingDirectory () AppDomain.CurrentDomain.ProcessExit.Add(fun _ -> restore ()) - let projectPath = argv[0] - for index, mutationCase in getMutationCases projectPath |> Seq.indexed do Console.ForegroundColor <- ConsoleColor.Green printf $"MUTATION {index + 1}\n"