diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2016-12-29 15:20:15 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2017-04-20 15:32:44 +0300 |
commit | 598a03684324eeac37e51f7606f8a27e1e9603e6 (patch) | |
tree | 0ff64573ab6fd9149cc45a928781146a4e1e359b /src/Main.hs | |
download | ire-598a03684324eeac37e51f7606f8a27e1e9603e6.tar.gz |
Initial release0.0.0
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..5070d8d --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,47 @@ +{-# LANGUAGE QuasiQuotes #-} +module Main ( + main +) where + +import Data.Maybe (fromJust) +import Data.Version (showVersion) +import Paths_ire (getDataDir, version) -- from cabal +import System.Environment (getArgs) +import Text.InterpolatedString.Perl6 (qc) +import qualified System.Console.Docopt.NoTH as O + +import IRE.Server (server) + +usage :: IO String +usage = do + dataDir <- getDataDir + return $ + "IRE " ++ showVersion version ++ + " - Watching you!" ++ [qc| + +Usage: + ire [options] + +Options: + -c, --config=FILE Configuration file [default: ire.yml] + + -r, --rootdir=DIR Web root directory with static files [default: {dataDir}] + -h, --help Show this message + +Note: + The default configuration file is loaded if found, + otherwise default built-in settings are used. + +|] + +main :: IO () +main = do + doco <- O.parseUsageOrExit =<< usage + args <- O.parseArgsOrExit doco =<< getArgs + if args `O.isPresent` O.longOption "help" + then putStrLn $ O.usage doco + else do + let configFile = fromJust . O.getArg args $ O.longOption "config" + rootDir = fromJust . O.getArg args $ O.longOption "rootdir" + server rootDir configFile + |