diff --git a/src/main/Main.hs b/src/main/Main.hs index 5fff4b3804f532cde584bb27aa0c1043949974c4..6425e7672a1daa0e34d68cf85ee78c347b325496 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -57,7 +57,7 @@ data Options = Options data SubCommand = HelpCommand HelpCommand | RefineCommand RefineOptions - | DotCommand DotOptions + | GraphCommand GraphOptions subcommand :: Parser SubCommand subcommand = @@ -70,11 +70,11 @@ subcommand = (progDesc "Refine the initial partition of a given coalgebra and output the result as a list of blocks of states."))) <> (command - "dot" + "graph" (info - (DotCommand <$> dotOptions) + (GraphCommand <$> graphOptions) (progDesc "Print coalgebra as graphviz graph." <> - footerDoc (Just (toAnsiWlPprint dotHelp))))) + footerDoc (Just (toAnsiWlPprint graphHelp))))) data RefineOptions = RefineOptions { refineStats :: Bool @@ -122,26 +122,26 @@ refineOptions = do \the input, but can also alternatively be given here.")) pure RefineOptions {..} -data DotOptions = DotOptions - { dotInputFile :: Maybe FilePath - , dotOutputFile :: Maybe FilePath - , dotFunctor :: Maybe (FunctorExpression SomeFunctor Sort) +data GraphOptions = GraphOptions + { graphInputFile :: Maybe FilePath + , graphOutputFile :: Maybe FilePath + , graphFunctor :: Maybe (FunctorExpression SomeFunctor Sort) } -dotHelp :: Doc AnsiStyle -dotHelp = +graphHelp :: Doc AnsiStyle +graphHelp = reflow "This command outputs a graph representation of the input coalgebra in graphviz format." <> softline <> - reflow "Use the dot(1) command to render the file as image." <> + reflow "Use the dot(1) command to render the file as an image." <> line <> line <> reflow "Nodes in the resulting graph are colored according to their sort. Labels depend on the functor." -dotOptions :: Parser DotOptions -dotOptions = do - dotInputFile <- +graphOptions :: Parser GraphOptions +graphOptions = do + graphInputFile <- optional (argument str @@ -151,7 +151,7 @@ dotOptions = do \See the \"help\" command for a description of available syntax." <> value "-" <> showDefault)) - dotOutputFile <- + graphOutputFile <- optional (argument str @@ -160,14 +160,14 @@ dotOptions = do "Name of the file to print the output to or \"-\" for standard output." <> value "-" <> showDefault)) - dotFunctor <- + graphFunctor <- optional (option functorReader (long "functor" <> short 'f' <> metavar "FUNCTOR_EXPR" <> help "Functor for the input coalgebra. This is normally the first line of \ \the input, but can also alternatively be given here.")) - pure DotOptions {..} + pure GraphOptions {..} functorReader :: ReadM (FunctorExpression SomeFunctor Sort) functorReader = eitherReader (\input -> parseFunctor input (T.pack input)) @@ -295,13 +295,13 @@ main = do finalizeStats stats - (DotCommand r) -> do + (GraphCommand r) -> do (_, (symbolTable, encoding)) <- do - readCoalgebra (dotFunctor r) (dotInputFile r) >>= \case + readCoalgebra (graphFunctor r) (graphInputFile r) >>= \case Left err -> hPutStrLn stderr err >> exitFailure Right res -> evaluate $ res - case dotOutputFile r of + case graphOutputFile r of Nothing -> printDot symbolTable encoding Just "-" -> printDot symbolTable encoding Just file -> writeDot file symbolTable encoding