summaryrefslogtreecommitdiff
path: root/Biz/Language/Bs/Cli.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Language/Bs/Cli.hs')
-rw-r--r--Biz/Language/Bs/Cli.hs46
1 files changed, 29 insertions, 17 deletions
diff --git a/Biz/Language/Bs/Cli.hs b/Biz/Language/Bs/Cli.hs
index 4c48c86..d2ac1e4 100644
--- a/Biz/Language/Bs/Cli.hs
+++ b/Biz/Language/Bs/Cli.hs
@@ -1,8 +1,10 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
-module Language.Bs.Cli (
- run
-) where
+
+module Language.Bs.Cli
+ ( run,
+ )
+where
import Data.String
import Data.Text.IO as TIO
@@ -17,12 +19,12 @@ import System.Directory
-- https://github.com/pcapriotti/optparse-applicative
-- https://hackage.haskell.org/package/optparse-applicative
-runScript :: FilePath -> IO ()
+runScript :: FilePath -> IO ()
runScript fname = do
exists <- doesFileExist fname
if exists
- then TIO.readFile fname >>= evalFile fname
- else TIO.putStrLn "File does not exist."
+ then TIO.readFile fname >>= evalFile fname
+ else TIO.putStrLn "File does not exist."
data LineOpts = UseReplLineOpts | RunScriptLineOpts String
@@ -30,14 +32,21 @@ parseLineOpts :: Parser LineOpts
parseLineOpts = runScriptOpt <|> runReplOpt
where
runScriptOpt =
- RunScriptLineOpts <$> strOption (long "script"
- <> short 's'
- <> metavar "SCRIPT"
- <> help "File containing the script you want to run")
+ RunScriptLineOpts
+ <$> strOption
+ ( long "script"
+ <> short 's'
+ <> metavar "SCRIPT"
+ <> help "File containing the script you want to run"
+ )
runReplOpt =
- UseReplLineOpts <$ flag' () (long "repl"
- <> short 'r'
- <> help "Run as interavtive read/evaluate/print/loop")
+ UseReplLineOpts
+ <$ flag'
+ ()
+ ( long "repl"
+ <> short 'r'
+ <> help "Run as interavtive read/evaluate/print/loop"
+ )
schemeEntryPoint :: LineOpts -> IO ()
schemeEntryPoint UseReplLineOpts = mainLoop --repl
@@ -46,7 +55,10 @@ schemeEntryPoint (RunScriptLineOpts script) = runScript script
run :: IO ()
run = execParser opts >>= schemeEntryPoint
where
- opts = info (helper <*> parseLineOpts)
- ( fullDesc
- <> header "Executable binary for Write You A Scheme v2.0"
- <> progDesc "contains an entry point for both running scripts and repl" )
+ opts =
+ info
+ (helper <*> parseLineOpts)
+ ( fullDesc
+ <> header "Executable binary for Write You A Scheme v2.0"
+ <> progDesc "contains an entry point for both running scripts and repl"
+ )