From 68af04a4da6ba4ec61d1469337ce53457526d861 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 23 Sep 2021 04:34:02 +0200 Subject: prettier pretty printing and stuff also, configurable log level, which only required relaxing the type system once! --- src/Main.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Main.hs b/src/Main.hs index 41f5da6..5072a64 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -17,6 +17,7 @@ import WithCli import Util (printPretty) import CheckDir (recursiveCheckDir) +import Types (Level(..)) -- | the options this cli tool can take data Options = Options @@ -26,10 +27,10 @@ data Options = Options -- ^ entrypoint in that repository , allowScripts :: Bool -- ^ pass --allowScripts to allow javascript in map - , scriptInject :: Maybe String - -- ^ optional filepath to javascript that should be injected , json :: Bool -- ^ emit json if --json was given + , lintlevel :: Maybe Level + -- ^ maximum lint level to print , pretty :: Bool -- ^ pretty-print the json to make it human-readable } deriving (Show, Generic, HasArguments) @@ -42,13 +43,14 @@ run :: Options -> IO () run options = do let repo = fromMaybe "." (repository options) let entry = fromMaybe "main.json" (entrypoint options) + let level = fromMaybe Suggestion (lintlevel options) lints <- recursiveCheckDir repo entry if json options then printLB $ if pretty options then encodePretty lints else encode lints - else printPretty lints + else printPretty (level, lints) -- | haskell's many string types are FUN … printLB :: LB.ByteString -> IO () -- cgit v1.2.3