summaryrefslogtreecommitdiffhomepage
path: root/Graphviz.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Graphviz.hs')
-rw-r--r--Graphviz.hs24
1 files changed, 5 insertions, 19 deletions
diff --git a/Graphviz.hs b/Graphviz.hs
index c6ce8a9..b85821c 100644
--- a/Graphviz.hs
+++ b/Graphviz.hs
@@ -5,11 +5,9 @@ module Graphviz (graphviz) where
import Types
import Hash
import CmdLine
+import Log
-import Data.Aeson
import Data.Char
-import Data.Word
-import Data.Either
import Data.Monoid
import Data.GraphViz
import Data.GraphViz.Attributes.Complete
@@ -24,22 +22,10 @@ import Data.Text.Encoding.Error
graphviz :: GraphvizOpts -> IO ()
graphviz opts = do
- parsed <- parseLog <$> L.readFile (graphvizLogFile opts)
- case lefts parsed of
- [] -> do
- let g = genGraph opts (rights parsed)
- f <- createImage (graphvizLogFile opts) Png g
- putStrLn ("Generated " ++ f)
- errs -> error $ unlines errs
-
-parseLog :: L.ByteString -> [Either String ActivityLog]
-parseLog = map eitherDecode'
- . filter (not . L.null)
- . L.split nl
-
-
-nl :: Word8
-nl = fromIntegral (ord '\n')
+ l <- loadLog (graphvizLogFile opts)
+ let g = genGraph opts l
+ f <- createImage (graphvizLogFile opts) Png g
+ putStrLn ("Generated " ++ f)
createImage :: PrintDotRepr dg n => FilePath -> GraphvizOutput -> dg n -> IO FilePath
createImage f o g = Data.GraphViz.addExtension (runGraphvizCommand Dot g) o f