X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemiaUI%2FArgs.fs;fp=Parasitemia%2FParasitemiaUI%2FArgs.fs;h=6c7416643f85bff2abf0335819a23c5f94bc7a3e;hp=0000000000000000000000000000000000000000;hb=cd9c55f80bcdc4fc6b85eb1b81474aed005e5016;hpb=2e029053d283ce141ce9870336cb9574ea4a203a diff --git a/Parasitemia/ParasitemiaUI/Args.fs b/Parasitemia/ParasitemiaUI/Args.fs new file mode 100644 index 0000000..6c74166 --- /dev/null +++ b/Parasitemia/ParasitemiaUI/Args.fs @@ -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