summaryrefslogtreecommitdiff
path: root/src/exe/Main.lhs
diff options
context:
space:
mode:
Diffstat (limited to 'src/exe/Main.lhs')
-rw-r--r--src/exe/Main.lhs34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/exe/Main.lhs b/src/exe/Main.lhs
index 2f67ffd..dc360fd 100644
--- a/src/exe/Main.lhs
+++ b/src/exe/Main.lhs
@@ -12,27 +12,20 @@ User interface
> import Codec.Pesto.Lint (lint, extractMetadata, Metadata(..), LintResult (LintResult))
> import Codec.Pesto.Serialize (serialize)
-The user-interface has different modes of operation. All of them read a single
-recipe from the standard input.
+The user-interface reads a single recipe from the standard input.
> main = do
> (op:_) <- getArgs
> s <- getContents
-> either malformedRecipe (run op) (parse s)
+> either malformedRecipe (run op) (parse s)
+
+It has three modes of operation, described in the next sections.
> run "dot" = runDot
> run "metadata" = runMeta
> run "ingredients" = runIngredients
> run _ = const (putStrLn "unknown operation")
-> malformedRecipe = print
-
-> streamToGraph stream = (nodes, edges)
-> where
-> doc = (head . extract . snd . unzip) stream
-> nodes = zip [firstNodeId..] doc
-> edges = toGraph nodes ++ resolveReferences nodes
-
dot
^^^
@@ -41,7 +34,7 @@ can represent recipes as well. Example:
.. code:: bash
- cabal run --verbose=0 pesto dot < spaghetti.pesto | dot -Tpng > spaghetti.png
+ cabal run --verbose=0 pesto dot < spaghetti.pesto | dot -Tpng > spaghetti.png
> runDot stream = putStrLn $ toDot dotNodes dotEdges
> where
@@ -50,10 +43,10 @@ can represent recipes as well. Example:
> (lintNodes, lintEdges) = unzip $ map (uncurry lintToNodesEdges)
> $ zip [maxId..] (lint nodes edges)
> dotNodes = concat [
-> [("node", [("fontname", "Roboto Semi-Light")])]
+> [("node", [("fontname", "Roboto Semi-Light")])]
> , map (\(a, label) -> (show a, [("label", serialize label)])) nodes
> , lintNodes
-> ]
+> ]
> dotEdges = concat [
> map (both show) edges
> , concat lintEdges
@@ -72,7 +65,7 @@ can represent recipes as well. Example:
> <> "}"
> where
> edgeToDot (a, b) = a <> " -> " <> b <> ";"
-> nodeToDot (a, b) = a <> " [" <> mconcat (mapToDot b) <> "];"
+> nodeToDot (a, b) = a <> " [" <> mconcat (mapToDot b) <> "];"
> mapToDot = map kvToDot
> kvToDot (k, v) = k <> "=\"" <> quoteString v <> "\""
@@ -104,3 +97,14 @@ alternatives into account yet.
> csvQty (Quantity a b c) = intercalate "," [serialize a, b, c]
+Appendix
+^^^^^^^^
+
+> malformedRecipe = print
+
+> streamToGraph stream = (nodes, edges)
+> where
+> doc = (head . extract . snd . unzip) stream
+> nodes = zip [firstNodeId..] doc
+> edges = toGraph nodes ++ resolveReferences nodes
+