41 lines
927 B
Idris
41 lines
927 B
Idris
|
module Options
|
||
|
|
||
|
import Data.String
|
||
|
import System
|
||
|
import System.Console.GetOpt
|
||
|
|
||
|
|
||
|
public export
|
||
|
record Options where
|
||
|
constructor Opts
|
||
|
tapVersion : String
|
||
|
|
||
|
defaultOpts = Opts {tapVersion = "13"}
|
||
|
|
||
|
OptMod = Options -> Options
|
||
|
|
||
|
opts : List (OptDescr OptMod)
|
||
|
opts = [
|
||
|
MkOpt ['V'] ["version"]
|
||
|
(ReqArg (\v => the OptMod {tapVersion := v}) "VERSION")
|
||
|
"TAP version to output (13 or 14, default 13)"
|
||
|
]
|
||
|
-- [todo] get rid of "the OptMod" when type inference is better, maybe
|
||
|
|
||
|
makeOpts : List OptMod -> Options
|
||
|
makeOpts = foldl (flip ($)) defaultOpts
|
||
|
|
||
|
|
||
|
getArgs1 : IO (List String)
|
||
|
getArgs1 =
|
||
|
case !getArgs of
|
||
|
_ :: args => pure args
|
||
|
[] => die "expecting getArgs to start with exe name"
|
||
|
|
||
|
export
|
||
|
getTestOpts : IO Options
|
||
|
getTestOpts =
|
||
|
case getOpt Permute opts !getArgs1 of
|
||
|
MkResult opts [] [] [] => pure $ makeOpts opts
|
||
|
res => die $ unlines $ res.errors ++ [usageInfo "quox test suite" opts]
|