summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstuebinm2021-09-23 04:34:02 +0200
committerstuebinm2021-09-23 04:34:58 +0200
commit68af04a4da6ba4ec61d1469337ce53457526d861 (patch)
treecb882c03ebe2c88450f16702cd4467a73e2c22a3 /src
parent04b98e4d62fe33b4fa357f2b52ffcc4f2c413302 (diff)
prettier pretty printing and stuff
also, configurable log level, which only required relaxing the type system once!
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs8
1 files changed, 5 insertions, 3 deletions
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 ()