-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
-
-let parseArgs (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 () =
- printfn "Usage of Parasitemia :"
- printfn "Non-interactive mode:"
- printfn " %s (--folder <folder>|--file <file>) --output <folder> [--debug]" System.AppDomain.CurrentDomain.FriendlyName
- printfn " --folder <folder> : an input folder containing images to analyze"
- printfn " --file <file> : an image file to be analyzed"
- printfn " --output <folder> : a folder to put the results"
- printfn " --debug : output more information like intermediate images if set"
-
- printfn "Interactive mode:"
- printfn " %s [<document-file>] [--debug]" System.AppDomain.CurrentDomain.FriendlyName
- printfn " <document-file> : a PIAZ file to automatically open at startup"
- printfn " --debug : output information like intermediate images if set in the current directory"
-