summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Main.hs24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/Main.hs b/src/Main.hs
index f4060b9..0e80eab 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -6,16 +6,17 @@
module Main where
-import Data.Aeson (encode)
-import Data.Aeson.Encode.Pretty (encodePretty)
-import qualified Data.ByteString.Lazy as LB
-import qualified Data.ByteString.Char8 as C8
-import Data.Maybe (fromMaybe)
+import Data.Aeson (encode)
+import Data.Aeson.Encode.Pretty (encodePretty)
+import qualified Data.ByteString.Char8 as C8
+import qualified Data.ByteString.Lazy as LB
+import Data.Maybe (fromMaybe)
import WithCli
-import Util (printPretty)
-import CheckDir (recursiveCheckDir)
-import Types (Level(..))
+import CheckDir (recursiveCheckDir,
+ writeAdjustedRepository)
+import Types (Level (..))
+import Util (printPretty)
-- | the options this cli tool can take
data Options = Options
@@ -27,10 +28,11 @@ data Options = Options
-- ^ pass --allowScripts to allow javascript in map
, json :: Bool
-- ^ emit json if --json was given
- , lintlevel :: Maybe Level
+ , lintlevel :: Maybe Level
-- ^ maximum lint level to print
, pretty :: Bool
-- ^ pretty-print the json to make it human-readable
+ , out :: Maybe String
} deriving (Show, Generic, HasArguments)
@@ -45,6 +47,10 @@ run options = do
lints <- recursiveCheckDir repo entry
+ case out options of
+ Just path -> writeAdjustedRepository path lints
+ Nothing -> pure ()
+
if json options
then printLB
$ if pretty options then encodePretty lints else encode lints