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

Safe HaskellNone
LanguageHaskell2010

UI.Butcher.Monadic.Interactive

Description

Utilities when writing interactive programs that interpret commands, e.g. a REPL.

Synopsis

Documentation

simpleCompletion Source #

Arguments

:: String

input string

-> CommandDesc ()

CommandDesc obtained on that input string

-> String

"remaining" input after the last successfully parsed subcommand. See runCmdParserExt.

-> String

completion, i.e. a string that might be appended to the current prompt when user presses tab.

Derives a potential completion from a given input string and a given CommandDesc. Considers potential subcommands and where available the completion info present in PartDescs.

shellCompletionWords Source #

Arguments

:: String

input string

-> CommandDesc ()

CommandDesc obtained on that input string

-> String

"remaining" input after the last successfully parsed subcommand. See runCmdParserExt.

-> [CompletionItem] 

Derives a list of completion items from a given input string and a given CommandDesc. Considers potential subcommands and where available the completion info present in PartDescs.

See addShellCompletion which uses this.

interactiveHelpDoc Source #

Arguments

:: String

input string

-> CommandDesc ()

CommandDesc obtained on that input string

-> String

"remaining" input after the last successfully parsed subcommand. See runCmdParserExt.

-> Int

max length of help text

-> Doc 

Produces a Doc as a hint for the user during interactive command input. Takes the current (incomplete) prompt line into account. For example when you have commands (among others) 'config set-email' and 'config get-email', then on empty prompt there will be an item 'config'; on the partial prompt 'config ' the help doc will contain the 'set-email' and 'get-email' items.

partDescStrings :: PartDesc -> [String] Source #

Obtains a list of "expected"/potential strings for a command part described in the PartDesc. In constrast to the simpleCompletion function this function does not take into account any current input, and consequently the output elements can in general not be appended to partial input to form valid input.