2022-05-01 18:19:09 -04:00
|
|
|
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
|
2022-05-04 11:09:49 -04:00
|
|
|
[] => do
|
|
|
|
putStrLn "expecting getArgs to start with exe name"
|
|
|
|
exitFailure
|
2022-05-01 18:19:09 -04:00
|
|
|
|
|
|
|
export
|
|
|
|
getTestOpts : IO Options
|
|
|
|
getTestOpts =
|
|
|
|
case getOpt Permute opts !getArgs1 of
|
|
|
|
MkResult opts [] [] [] => pure $ makeOpts opts
|
2022-05-04 11:09:49 -04:00
|
|
|
res => do
|
|
|
|
traverse_ putStrLn $ res.errors ++ [usageInfo "quox test suite" opts]
|
|
|
|
exitFailure
|