diff options
Diffstat (limited to 'Biz/Cli.hs')
-rw-r--r-- | Biz/Cli.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Biz/Cli.hs b/Biz/Cli.hs new file mode 100644 index 0000000..f2d7fad --- /dev/null +++ b/Biz/Cli.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE NoImplicitPrelude #-} + +-- : dep docopt +module Biz.Cli + ( Plan (..), + main, + Docopt.Docopt (..), + Docopt.Arguments, + Docopt.argument, + Docopt.docopt, + Docopt.getAllArgs, + ) +where + +import Alpha +import qualified System.Console.Docopt as Docopt +import qualified System.Environment as Environment + +data Plan = Plan + { help :: Docopt.Docopt, + move :: Docopt.Arguments -> IO (), + test :: Docopt.Arguments -> IO () + } + +main :: Plan -> IO () +main Plan {..} = + Environment.getArgs + >>= Docopt.parseArgsOrExit help + >>= \args -> + if args `has` Docopt.longOption "test" + then test args + else move args + +has :: Docopt.Arguments -> Docopt.Option -> Bool +has = Docopt.isPresent |