Verified Commit a9291252 authored by Camil Staps's avatar Camil Staps 🚀

Accept input file as operand

parent b38832ba
module profile2html
import StdEnv
import StdMaybe
import Data.Error
import Data.Func
......@@ -31,12 +32,13 @@ Start w
# ([prog:args],w) = getCommandLine w
# args = parseOptions option_description args defaultOptions
| isError args
= exit (join "\n" (fromError args)) w
= exit (join "\n" [usage prog,"":fromError args]) w
# args = fromOk args
| args.input==""
= exit "Specify an input file with -i/--input" w
| args.output==""
= exit "Specify an output file with -o/--output" w
| size args.input==0
= exit "Specify an input file" w
# args & output = if (size args.output==0)
(addExtension args.input "html")
args.output
# (ok,input,w) = fopen args.input FReadData w
| not ok
= exit "Could not open input file" w
......@@ -52,12 +54,14 @@ Start w
# (_,w) = fclose f w
= w
where
option_description = WithHelp True $ Options
[ Shorthand "-i" "--input" $ Option "--input"
(\ip opts -> Ok {opts & input=ip})
"INPUT"
"The input file"
, Shorthand "-o" "--output" $ Option "--output"
usage prog = concat
[ "Usage: "
, prog
, " [options] INPUT"
]
option_description =
WithHelp True $ Options
[ Shorthand "-o" "--output" $ Option "--output"
(\op opts -> Ok {opts & output=op})
"OUTPUT"
"The output file"
......@@ -75,6 +79,14 @@ where
-> Ok {opts & min_cumulative_ticks=t})
"N"
"Only include cost centres with at least N ticks (cumulatively)"
, Operand
False
(\ip opts
| size opts.input==0
-> Just (Ok {opts & input=ip})
-> Nothing)
"INPUT"
"The input file"
]
exit err w
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment