summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-05-07 23:28:18 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2016-05-07 23:28:18 +0200
commit6ceaff1e8e111d6b025bd725ee93edb354c535f6 (patch)
tree686da728bcc5793f174bd2fb5c8d288e655b16ca /src/Main.hs
parent043d2266e791f86835e82b76426990dba3aed9a0 (diff)
download2017-01-16_17:13:37-6ceaff1e8e111d6b025bd725ee93edb354c535f6.tar
2017-01-16_17:13:37-6ceaff1e8e111d6b025bd725ee93edb354c535f6.tar.gz
2017-01-16_17:13:37-6ceaff1e8e111d6b025bd725ee93edb354c535f6.tar.bz2
2017-01-16_17:13:37-6ceaff1e8e111d6b025bd725ee93edb354c535f6.tar.xz
2017-01-16_17:13:37-6ceaff1e8e111d6b025bd725ee93edb354c535f6.zip
command parsing with optparse-applicative
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/Main.hs b/src/Main.hs
index e6a3024..0088b7c 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -35,18 +35,16 @@ main = do
35runCli :: (MonadIO m, MonadException m) => SequenceT m () 35runCli :: (MonadIO m, MonadException m) => SequenceT m ()
36runCli = do 36runCli = do
37 input <- lift $ getInputLine "→ " 37 input <- lift $ getInputLine "→ "
38 cmnd <- maybe (return $ ParseError "Trying to parse EOF") parseCmd input
39 case input of 38 case input of
40 Nothing -> liftIO exitSuccess 39 Nothing -> liftIO exitSuccess
41 Just _ -> do 40 Just input' -> do
42 case cmnd of 41 case parseCmd input' of
43 UnknownCommand cmd -> do 42 UnknownCommand help -> do
44 lift . outputStrLn $ "Unknown command: »" <> cmd <> "«" 43 lift . outputStrLn $ help
45 ParseError err -> do 44 ParseError err -> do
46 lift . outputStrLn $ "Error parsing input »" <> (fromMaybe "" input) <> "«: " <> err 45 lift . outputStrLn $ "Error parsing input »" <> (fromMaybe "" input) <> "«: " <> err
47 Empty -> return () 46 Empty -> return ()
48 47
49 Quit -> liftIO exitSuccess 48 Quit -> liftIO exitSuccess
50 PerformAlt alt -> apply' alt 49 _ -> undefined
51 Step -> undefined
52 runCli 50 runCli