summaryrefslogtreecommitdiffhomepage
path: root/Graphviz.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-18 11:39:16 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-18 11:39:16 -0400
commitdc7e4be27070421022d7d37a9b8d13f73c7667c7 (patch)
treef239ff17ce66d4f6bd92a6be01fa039e14bfa1d4 /Graphviz.hs
parent5e81ebbd1a6f8911acd537923f2f3c1df4971bbc (diff)
downloaddebug-me-dc7e4be27070421022d7d37a9b8d13f73c7667c7.tar.gz
add --show-hashes
Diffstat (limited to 'Graphviz.hs')
-rw-r--r--Graphviz.hs20
1 files changed, 11 insertions, 9 deletions
diff --git a/Graphviz.hs b/Graphviz.hs
index d4db9d3..6a5cb52 100644
--- a/Graphviz.hs
+++ b/Graphviz.hs
@@ -4,6 +4,7 @@ module Graphviz (graphviz) where
import Types
import Hash
+import CmdLine
import Data.Aeson
import Data.Char
@@ -21,13 +22,13 @@ import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.Encoding as T
import Data.Text.Encoding.Error
-graphviz :: FilePath -> IO ()
-graphviz logfile = do
- parsed <- parseLog <$> L.readFile logfile
+graphviz :: GraphvizOpts -> IO ()
+graphviz opts = do
+ parsed <- parseLog <$> L.readFile (graphvizLogFile opts)
case lefts parsed of
[] -> do
- let g = genGraph (rights parsed)
- f <- createImage logfile Png g
+ let g = genGraph opts (rights parsed)
+ f <- createImage (graphvizLogFile opts) Png g
putStrLn ("Generated " ++ f)
errs -> error $ unlines errs
@@ -43,8 +44,8 @@ nl = fromIntegral (ord '\n')
createImage :: PrintDotRepr dg n => FilePath -> GraphvizOutput -> dg n -> IO FilePath
createImage f o g = Data.GraphViz.addExtension (runGraphvizCommand Dot g) o f
-genGraph :: [ActivityLog] -> G.DotGraph T.Text
-genGraph ls = digraph (Str "debug-me") $ do
+genGraph :: GraphvizOpts -> [ActivityLog] -> G.DotGraph T.Text
+genGraph opts ls = digraph (Str "debug-me") $ do
nodeAttrs [style filled]
forM_ ls $
showactivity [ xcolor Green ]
@@ -76,8 +77,9 @@ genGraph ls = digraph (Str "debug-me") $ do
Nothing -> return ()
Just p -> link p h s
link a b s = edge (display a) (display b) $ s ++
- [ textLabel (shorthash a)
- ]
+ if graphvizShowHashes opts
+ then [ textLabel (shorthash a) ]
+ else []
-- The "h:" prefix is to work around this bug:
-- https://github.com/ivan-m/graphviz/issues/16
shorthash h = display $ Val $ "h:" <> (B.take 5 $ val $ hashValue h)