summaryrefslogtreecommitdiff
path: root/Biz/Cli.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Cli.hs')
-rw-r--r--Biz/Cli.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/Biz/Cli.hs b/Biz/Cli.hs
index b3c7583..5029792 100644
--- a/Biz/Cli.hs
+++ b/Biz/Cli.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}
@@ -33,14 +35,16 @@ data Plan cfg = Plan
main :: Plan cfg -> IO ()
main Plan {..} =
Environment.getArgs
- +> Docopt.parseArgsOrExit help
- +> \args ->
- if args `has` Docopt.command "test"
- then Test.run test
- else
- if args `has` Docopt.longOption "help" || args `has` Docopt.shortOption 'h'
- then Docopt.exitWithUsage help
- else move args
+ /> Docopt.parseArgs help
+ +> \case
+ Left err -> panic <| show err
+ Right args ->
+ if args `has` Docopt.command "test"
+ then Test.run test
+ else
+ if args `has` Docopt.longOption "help" || args `has` Docopt.shortOption 'h'
+ then Docopt.exitWithUsage help
+ else move args
has :: Docopt.Arguments -> Docopt.Option -> Bool
has = Docopt.isPresent