From 6ceaff1e8e111d6b025bd725ee93edb354c535f6 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 7 May 2016 23:28:18 +0200 Subject: command parsing with optparse-applicative --- src/Main.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/Main.hs') 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 runCli :: (MonadIO m, MonadException m) => SequenceT m () runCli = do input <- lift $ getInputLine "→ " - cmnd <- maybe (return $ ParseError "Trying to parse EOF") parseCmd input case input of Nothing -> liftIO exitSuccess - Just _ -> do - case cmnd of - UnknownCommand cmd -> do - lift . outputStrLn $ "Unknown command: »" <> cmd <> "«" + Just input' -> do + case parseCmd input' of + UnknownCommand help -> do + lift . outputStrLn $ help ParseError err -> do lift . outputStrLn $ "Error parsing input »" <> (fromMaybe "" input) <> "«: " <> err Empty -> return () Quit -> liftIO exitSuccess - PerformAlt alt -> apply' alt - Step -> undefined + _ -> undefined runCli -- cgit v1.2.3