summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstuebinm2021-12-30 23:35:10 +0100
committerstuebinm2021-12-30 23:35:10 +0100
commit8f292660630b3154a3441cc673d6aa605f668e5b (patch)
tree183d57f89c9dd8811d2cf7141d63a13d7df18074 /src
parent09f6bbdad52e58a3d128c9806078d359832f07e1 (diff)
add dot language output for repository map graphs
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 9bc09ff..02e8f02 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE MultiWayIf #-}
module Main where
@@ -18,7 +19,7 @@ import qualified Data.Text.IO as T
import System.Exit (ExitCode (..), exitWith)
import WithCli
-import CheckDir (recursiveCheckDir, resultIsFatal)
+import CheckDir (recursiveCheckDir, resultIsFatal, DirResult (dirresultGraph))
import Control.Monad (when)
import LintConfig (LintConfig (..), patchConfig)
import System.IO (hPutStrLn, stderr)
@@ -26,6 +27,7 @@ import Types (Level (..))
import Util (printPretty)
import qualified Version as V (version)
import WriteRepo (writeAdjustedRepository)
+import Text.Dot (showDot)
-- | the options this cli tool can take
data Options = Options
@@ -46,6 +48,7 @@ data Options = Options
, config :: Maybe (LintConfig Maybe)
-- ^ a "patch" for the configuration file
, version :: Bool
+ , dot :: Bool
} deriving (Show, Generic, HasArguments)
@@ -73,10 +76,12 @@ run options = do
lints <- recursiveCheckDir lintconfig repo entry
- if json options
- then printLB
- $ if pretty options then encodePretty lints else encode lints
- else printPretty (level, lints)
+ if | dot options ->
+ putStrLn (showDot $ dirresultGraph lints)
+ | json options ->
+ printLB
+ $ if pretty options then encodePretty lints else encode lints
+ | otherwise -> printPretty (level, lints)
case out options of
Nothing -> exitWith $ case resultIsFatal lintconfig lints of