summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstuebinm2021-11-09 20:24:17 +0100
committerstuebinm2021-11-09 20:42:10 +0100
commit652c2030c5ef39bf1dd34d26064e1059431898f0 (patch)
tree7100fbdfabbfa0f237e05ae1d0d2e2debb380125 /src
parentd0dc669c495f5f9e3dae20481e0aae183f606519 (diff)
first example of a map adjustment
this also includes some more monad plumbing, and an option for the linter to actually write things out again. Some of the previous commit was reverted a bit since it turned out to be stupid, but overall it was suprisingly easy once I got around to it, so yay! i guess Also includes a fairly silly example of how to use it.
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