take the usage info header as an argument

oops!
This commit is contained in:
rhiannon morris 2023-02-22 21:56:02 +01:00
parent 8428d0dd06
commit 4dba693a5f

View file

@ -84,6 +84,7 @@ private
setFilter : String -> Mod
setFilter str opts = pure $ {pattern := Just str} opts
parameters (header : String)
mutual
||| option descriptions
export
@ -119,7 +120,7 @@ mutual
||| usage message
export
usage : List String
usage = assert_total $ "quox test suite" :: lines (usageInfo "" opts)
usage = assert_total $ header :: lines (usageInfo "" opts)
||| interpret the result of `getOpt`
@ -137,19 +138,20 @@ getArgs1 =
[] => failureWith ["expected getArgs to start with exe name"]
||| read & interpret the command line arguments
||| read & interpret the command line arguments.
||| the first argument is the header to print on the usage message.
|||
||| [todo] allow unrecognised things and pass them back out
export
getTestOpts' : List String -> IO Options
getTestOpts' args =
case getOpt Permute opts args of
getTestOpts' : String -> List String -> IO Options
getTestOpts' header args =
case getOpt Permute (opts header) args of
MkResult opts [] [] [] => makeOpts opts
res => failureWith $ res.errors ++ usage
res => failureWith $ res.errors ++ usage header
||| interpret some command line arguments passed in
|||
||| [todo] allow unrecognised things and pass them back out
export
getTestOpts : IO Options
getTestOpts = getTestOpts' !getArgs1
getTestOpts : String -> IO Options
getTestOpts header = getTestOpts' header !getArgs1