craft_cli.helptexts module

Provide all help texts.

class craft_cli.helptexts.HelpBuilder(appname, general_summary, command_groups)[source]

Bases: object

Produce the different help texts.

Parameters
  • appname (str) –

  • general_summary (str) –

  • command_groups (List[ForwardRef]) –

get_command_help(command, arguments, output_format)[source]

Produce the text for each command’s help in any output format.

  • command: the instantiated command for which help is prepared

  • arguments: all command options and parameters, with the (name, description) structure;

    note that any argument with description being HIDDEN will be ignored

  • output_format: the selected output format

The help text structure depends of the output format.

Parameters
Return type

str

get_detailed_help(global_options)[source]

Produce the text for the detailed help.

  • global_options: options defined at application level (not in the commands), with the (options, description) structure

The help text has the following structure:

  • usage

  • summary

  • global options

  • all commands shown with description, grouped

  • more help

Parameters

global_options (List[Tuple[str, str]]) –

Return type

str

get_full_help(global_options)[source]

Produce the text for the default help.

  • global_options: options defined at application level (not in the commands), with the (options, description) structure

The help text has the following structure:

  • usage

  • summary

  • common commands listed and described shortly

  • all commands grouped, just listed

  • more help

Parameters

global_options (List[Tuple[str, str]]) –

Return type

str

get_usage_message(error_message, command='')[source]

Build a usage and error message.

The command is the extra string used after the application name to build the full command that will be shown in the usage message; for example, having an application name of “someapp”: - if command is “” it will be shown “Try ‘appname -h’ for help”. - if command is “version” it will be shown “Try ‘appname version -h’ for help”

The error message is the specific problem in the given parameters.

Parameters
  • error_message (str) –

  • command (str) –

Return type

str

class craft_cli.helptexts.OutputFormat(value)

Bases: enum.Enum

An enumeration.

markdown = 2
plain = 1
craft_cli.helptexts.process_overview_for_markdown(text)[source]

Process a regular overview to be rendered with markdown.

In detail:

  • Join all lines for the same paragraph (as wrapping is responsibility of the renderer)

  • Dedent and wrap with triple-backtick all indented blocks

Paragraphs are separated by empty lines

Parameters

text (str) –

Return type

str