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

Safe HaskellNone
LanguageHaskell2010

UI.Butcher.Monadic.BuiltinCommands

Description

Some CmdParser actions that add predefined commands.

Synopsis

Documentation

addHelpCommand :: Applicative f => CommandDesc a -> CmdParser f (IO ()) () Source #

Adds a proper full help command. To obtain the CommandDesc value, see cmdRunParserWithHelpDesc or mainFromCmdParserWithHelpDesc.

addHelpCommand = addHelpCommandWith
  (pure . PP.renderStyle PP.style { PP.ribbonsPerLine = 1.0 } . ppHelpShallow)

addHelpCommand2 :: Applicative f => CommandDesc a -> CmdParser f (IO ()) () Source #

Adds a proper full help command. In contrast to addHelpCommand, this version is a bit more verbose about available subcommands as it includes their synopses.

To obtain the CommandDesc value, see cmdRunParserWithHelpDesc or mainFromCmdParserWithHelpDesc.

addHelpCommand2 = addHelpCommandWith
  (pure . PP.renderStyle PP.style { PP.ribbonsPerLine = 1.0 } . ppHelpDepthOne)

addHelpCommandWith :: Applicative f => (CommandDesc a -> IO String) -> CommandDesc a -> CmdParser f (IO ()) () Source #

Adds a proper full help command, using the specified function to turn the relevant subcommand's CommandDesc into a String.

addHelpCommandShallow :: Applicative f => CmdParser f (IO ()) () Source #

Adds a help command that prints help for the command currently in context.

This version does _not_ include further childcommands, i.e. "help foo" will not print the help for subcommand "foo".

This also yields slightly different output depending on if it is used before or after adding other subcommands. In general addHelpCommand should be preferred.

addButcherDebugCommand :: Applicative f => CmdParser f (IO ()) () Source #

Prints the raw CommandDesc structure.

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

Adds the "completion" command and several subcommands.

This command can be used in the following manner:

$ source <(foo completion bash-script foo)

addShellCompletionCommand' :: (CommandDesc out -> CmdParser Identity (IO ()) ()) -> CmdParser Identity (IO ()) () Source #

Adds the "completion" command and several subcommands

This command can be used in the following manner:

$ source <(foo completion bash-script foo)