Output logs to AppUser/Roaming/Parasitemia/Logs
[master-thesis.git] / Parasitemia / ParasitemiaUI / Args.fs
diff --git a/Parasitemia/ParasitemiaUI/Args.fs b/Parasitemia/ParasitemiaUI/Args.fs
new file mode 100644 (file)
index 0000000..6c74166
--- /dev/null
@@ -0,0 +1,33 @@
+module ParasitemiaUI.Args
+
+open System
+
+type Input =
+    | File of string
+    | Dir of string
+
+type RunningMode =
+    | CmdLine of Input * string // A file or a directory to process and the output directory.
+    | Window of string option // An optional path to a file to open can be given in window mode.
+
+type Arguments = RunningMode * bool // bool : true if in debug mode.
+
+let parse (args : string[]) : Arguments =
+
+    let output = Array.tryFindIndex ((=) "--output") args
+
+    let runningMode =
+        match Array.tryFindIndex ((=) "--folder") args, output with
+        | Some i, Some i_output when i < args.Length - 2 && i_output < args.Length - 2 ->
+            CmdLine ((Dir args.[i + 1]), args.[i_output + 1])
+        | _ ->
+            match Array.tryFindIndex ((=) "--file") args, output with
+            | Some i, Some i_output when i < args.Length - 2 && i_output < args.Length - 2 ->
+                CmdLine ((File args.[i + 1]), args.[i_output + 1])
+            |_ ->
+                Window (if args.Length > 0 && not (args.[0].StartsWith ("--")) then Some args.[0] else None)
+
+    runningMode, Array.exists ((=) "--debug") args
+
+let showArgsHelp () =
+    Console.WriteLine Utils.argsHelp
\ No newline at end of file