craft_cli.helptexts module¶
Provide all help texts.
- class craft_cli.helptexts.OutputFormat(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
- plain = 1¶
- markdown = 2¶
- craft_cli.helptexts.process_overview_for_markdown(text: str) str [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
- class craft_cli.helptexts.HelpBuilder(appname: str, general_summary: str, command_groups: list[CommandGroup], docs_base_url: str | None = None)[source]¶
Bases:
object
Produce the different help texts.
- get_usage_message(error_message: str, command: str = '') str [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.
- get_full_help(global_options: list[tuple[str, str]]) str [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 and documentation
- get_detailed_help(global_options: list[tuple[str, str]]) str [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 and documentation
- get_command_help(command: BaseCommand, arguments: list[tuple[str, str]], output_format: OutputFormat) str [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.