From 8f292660630b3154a3441cc673d6aa605f668e5b Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 30 Dec 2021 23:35:10 +0100 Subject: add dot language output for repository map graphs --- src/Main.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/Main.hs') 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 -- cgit v1.2.3