Safe Haskell | None |
---|---|
Language | Haskell2010 |
Pretty-print of CommandDescs. To explain what the different functions do, we will use an example CmdParser. The CommandDesc derived from that CmdParser will serve as example input to the functions in this module.
main = mainFromCmdParserWithHelpDesc $ \helpDesc -> do addCmdSynopsis "a simple butcher example program" addCmdHelpStr "a very long help document" addCmd "version" $ do porcelain <- addSimpleBoolFlag "" ["porcelain"] (flagHelpStr "print nothing but the numeric version") addCmdHelpStr "prints the version of this program" addCmdImpl $ putStrLn $ if porcelain then "0.0.0.999" else "example, version 0.0.0.999" addCmd "help" $ addCmdImpl $ print $ ppHelpShallow helpDesc short <- addSimpleBoolFlag "" ["short"] (flagHelpStr "make the greeting short") name <- addStringParam "NAME" (paramHelpStr "your name, so you can be greeted properly") addCmdImpl $ do if short then putStrLn $ "hi, " ++ name ++ "!" else putStrLn $ "hello, " ++ name ++ ", welcome from butcher!"
- ppUsage :: CommandDesc a -> Doc
- ppUsageAt :: [String] -> CommandDesc a -> Maybe Doc
- ppHelpShallow :: CommandDesc a -> Doc
- ppUsageWithHelp :: CommandDesc a -> Doc
- ppPartDescUsage :: PartDesc -> Doc
- ppPartDescHeader :: PartDesc -> Doc
- parsingErrorString :: ParsingError -> String
Documentation
ppUsage :: CommandDesc a -> Doc #
ppUsage exampleDesc yields:
playground [--short] NAME [version | help]
ppUsageAt :: [String] -> CommandDesc a -> Maybe Doc #
ppUsageAt [] = ppUsage
fromJust $ ppUsageAt ["version"] exampleDesc yields:
example version [--porcelain]
ppHelpShallow :: CommandDesc a -> Doc #
ppHelpShalloe exampleDesc yields:
NAME example - a simple butcher example program USAGE example [--short] NAME [version | help] DESCRIPTION a very long help document ARGUMENTS --short make the greeting short NAME your name, so you can be greeted properly
ppUsageWithHelp :: CommandDesc a -> Doc #
ppUsageWithHelp exampleDesc yields:
playground [--short] NAME [version | help]: a simple butcher example program
And yes, the line break is not optimal in this instance with default print.
ppPartDescUsage :: PartDesc -> Doc #
Internal helper; users probably won't need this.
ppPartDescHeader :: PartDesc -> Doc #
Internal helper; users probably won't need this.
parsingErrorString :: ParsingError -> String #
Simple conversion from ParsingError
to String
.