aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@valuemotive.com>2022-09-23 10:45:20 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-05 14:21:52 +0200
commit11ba54ee5c0f3dfd0c3d62a1943d87426280f84d (patch)
tree4368142662e1a80cf96849a0bd8dd7ad40686ed1 /app
parentfd39958d20554fdc19611c5f23d32c8493ad655e (diff)
Add help
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs30
1 files changed, 17 insertions, 13 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 669a66e..3e92547 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -19,6 +19,8 @@ parseArgs config args =
main :: IO ()
main = do
args <- getArgs
+ progName <- getProgName
+
let initialConfig = Config {
configScriptFileName = Nothing,
configVerboseMode = False,
@@ -27,19 +29,21 @@ main = do
let config = parseArgs initialConfig args
- when (configVerboseMode config) $ do
- putStrLn $ "configScriptFileName:\t" ++ (show $ configScriptFileName config)
- putStrLn $ "configVerboseMode:\t" ++ (show $ configVerboseMode config)
-
- when (configShowHelp config) $ do
- error "TODO help"
+ if (configShowHelp config) then do
+ putStrLn $ "Usage: " ++ progName ++ " # to open REPL"
+ putStrLn $ " " ++ progName ++ " -i scriptFile # to run script file"
+ putStrLn $ " " ++ progName ++ " -h # to show this help"
+ else do
+ when (configVerboseMode config) $ do
+ putStrLn $ "configScriptFileName:\t" ++ (show $ configScriptFileName config)
+ putStrLn $ "configVerboseMode:\t" ++ (show $ configVerboseMode config)
- case (configScriptFileName config) of
- Just scriptFileName -> do
- result <- runExceptT $ runReaderT (runScriptFile scriptFileName) config
- case result of
- Left (LException ex) -> putStrLn $ "Error: " ++ ex
- Right () -> return ()
- Nothing -> error "TODO REPL"
+ case (configScriptFileName config) of
+ Just scriptFileName -> do
+ result <- runExceptT $ runReaderT (runScriptFile scriptFileName) config
+ case result of
+ Left (LException ex) -> putStrLn $ "Error: " ++ ex
+ Right () -> return ()
+ Nothing -> error "TODO REPL"
return ()