butcher-1.3.3.2: Chops a command or program invocation into digestable pieces.

Safe Haskell | None
Language | Haskell2010

UI.Butcher.Monadic.IO

Description

Turn your CmdParser into an IO () to be used as your program `main`.

Synopsis

- mainFromCmdParser :: CmdParser Identity (IO ()) () -> IO ()
- mainFromCmdParserWithHelpDesc :: (CommandDesc () -> CmdParser Identity (IO ()) ()) -> IO ()

# Documentation

mainFromCmdParser :: CmdParser Identity (IO ()) () -> IO () Source #

Utility method that allows using a `CmdParser` as your `main` function:

    main = mainFromCmdParser $ do
      addCmdImpl $ putStrLn "This is a fairly boring program."

Uses `System.Environment.getProgName` as program name and `System.Environment.getArgs` as the input to be parsed. Prints some appropriate messages if parsing fails or if the command has no implementation; if all is well executes the 'out' action (the IO ()).

mainFromCmdParserWithHelpDesc :: (CommandDesc () -> CmdParser Identity (IO ()) ()) -> IO () Source #

Same as mainFromCmdParser, but with one additional twist: You get access to a knot-tied complete CommandDesc for this full command. Useful in combination with `addHelpCommand`