blob: aa7c45e775770fc60eb6b3fe423f544b1c082952 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import Prelude hiding (log)
import Control.Monad
import Data.List
import Data.Maybe
import System
import Bustle.Parser (readLog)
import Bustle.Types
run :: FilePath -> IO ()
run filepath = do
input <- readFile filepath
case readLog input of
Left err -> putStrLn $ concat ["Couldn't parse ", filepath, ": ", show err]
Right log -> do
putStrLn "digraph bustle {"
forM_ (nub . mapMaybe methodCall $ log)
(\(s, d) -> putStrLn . concat $
[" \"", unBusName s, "\" -> \"", unBusName d, "\";"])
putStrLn "}"
where methodCall (MethodCall {sender = s, destination = d}) = Just (s, d)
methodCall _ = Nothing
main :: IO ()
main = do
args <- getArgs
case args of
[filepath] -> run filepath
_ -> exitFailure
|