Save imported image in the same format (WIP)
[master-thesis.git] / Parasitemia / ParasitemiaUI / Args.fs
1 module ParasitemiaUI.Args
2
3 open System
4
5 type Input =
6 | File of string
7 | Dir of string
8
9 type RunningMode =
10 | CmdLine of Input * string // A file or a directory to process and the output directory.
11 | Window of string option // An optional path to a file to open can be given in window mode.
12
13 type Arguments = RunningMode * bool // bool : true if in debug mode.
14
15 let parse (args : string[]) : Arguments =
16
17 let output = Array.tryFindIndex ((=) "--output") args
18
19 let runningMode =
20 match Array.tryFindIndex ((=) "--folder") args, output with
21 | Some i, Some i_output when i < args.Length - 2 && i_output < args.Length - 2 ->
22 CmdLine ((Dir args.[i + 1]), args.[i_output + 1])
23 | _ ->
24 match Array.tryFindIndex ((=) "--file") args, output with
25 | Some i, Some i_output when i < args.Length - 2 && i_output < args.Length - 2 ->
26 CmdLine ((File args.[i + 1]), args.[i_output + 1])
27 |_ ->
28 Window (if args.Length > 0 && not (args.[0].StartsWith ("--")) then Some args.[0] else None)
29
30 runningMode, Array.exists ((=) "--debug") args
31
32 let showArgsHelp () =
33 Console.WriteLine Utils.argsHelp