diff options
Diffstat (limited to 'tests/TestOptions.hs')
-rw-r--r-- | tests/TestOptions.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/TestOptions.hs b/tests/TestOptions.hs new file mode 100644 index 0000000..0504f8f --- /dev/null +++ b/tests/TestOptions.hs @@ -0,0 +1,33 @@ +module TestOptions + ( ModProgs + , testOpts + ) where + +import System.Console.GetOpt as GetOpt + +import CabalHelper.Compiletime.Types + +type ModProgs = (Programs -> Programs) + +options :: [OptDescr ModProgs] +options = + [ GetOpt.Option [] ["with-cabal"] + (ReqArg (\arg -> \p -> p { cabalProgram = arg }) "PROG") + "name or path of 'cabal' executable" + , GetOpt.Option [] ["with-stack"] + (ReqArg (\arg -> \p -> p { stackProgram = arg }) "PROG") + "name or path of 'stack' executable" + , GetOpt.Option [] ["with-ghc"] + (ReqArg (\arg -> \cp -> cp { ghcProgram = arg }) "PROG") + "name or path of 'ghc' executable" + , GetOpt.Option [] ["with-ghc-pkg"] + (ReqArg (\arg -> \cp -> cp { ghcPkgProgram = arg }) "PROG") + "name or path of 'ghc-pkg' executable" + ] + +testOpts :: [String] -> IO (ModProgs, [String]) +testOpts args = + case getOpt Permute options args of + (o,n,[] ) -> return (foldl (flip (.)) id o, n) + (_,_,errs) -> ioError (userError (concat errs ++ usageInfo header options)) + where header = "Usage: ghc-session [OPTION..] [TEST_SPEC..]" |