diff options
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/Main.hs b/src/Main.hs index c819300..9619f7a 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -25,6 +25,8 @@ import Control.Exception (ioError) import System.Console.GetOpt import System.IO.Error (userError) import Zettel +import Control.Logging +import qualified Data.Text as T -- data HeaderState = HeaderState -- { headerStateMap :: Map Text ((ZettelId, Text), [Text]), @@ -211,7 +213,7 @@ data Options = Options optCsl :: Maybe FilePath, optIndex :: Maybe FilePath, optOutput :: Maybe FilePath, - optVerbose :: Bool, + optVerbose :: Int, optQuiet :: Bool, optShowVersion :: Bool, optShowHelp :: Bool @@ -226,7 +228,7 @@ defaultOptions = optCsl = Nothing, optIndex = Nothing, optOutput = Nothing, - optVerbose = False, + optVerbose = 0, optQuiet = False, optShowVersion = False, optShowHelp = False @@ -272,7 +274,7 @@ options = Option ['v'] ["verbose"] - (NoArg (\opts -> opts {optVerbose = True})) + (NoArg (\opts -> opts {optVerbose = optVerbose opts + 1})) "Verbose output while processing files", Option ['V', '?'] @@ -294,9 +296,16 @@ compilerOpts argv = (_, _, errs) -> ioError (userError (concat errs ++ usageInfo headerOpts options)) main :: IO () -main = do +main = withStderrLogging $ do (zkOpts, fl) <- getArgs >>= compilerOpts + setLogLevel LevelWarn + when (optVerbose zkOpts == 1) $ setLogLevel LevelInfo + when (optVerbose zkOpts > 1) $ setLogLevel LevelDebug + when (optQuiet zkOpts) $ setLogLevel LevelError + + debug $ "Options: " <> T.pack (show zkOpts) + when (optShowHelp zkOpts) $ do putStrLn $ usageInfo headerOpts options exitSuccess @@ -309,8 +318,10 @@ main = do let pipeline = transcludeMdAll >> linkAll >> wrapZettelGraph >> handleBibliography + when (isNothing (optCsl zkOpts)) . warn $ "CSL file not set, using: ieee.csl" + when (isNothing (optBibliography zkOpts)) . warn $ "Bibliography file not set, using: references.bib" + renderZettelGraphFile - (optVerbose zkOpts) ( fromMaybe "ieee.csl" (optCsl zkOpts) |