Help functionality

Functions for displaying command-line help

This module contains all the documentation and functionality needed for the ‘abed help’ command.

abed.help.bold(text)[source]

Add bold escape sequences to text

This adds the '\033[1m' before the string, and '\033[0m' after the string.

Parameters

text (str) – Text to include in escape sequences for bold text

Returns

Text surrounded by escape sequences

Return type

str

abed.help.cmd_strings(cmds)[source]

Format commands with short help for general help text

Given a list of commands, this formats the help text in the form:

command     short description

The formatting is done such that the short descriptions of all the commands line up in the same way, and long descriptions are continued on the next line at the correct indentation.

Parameters

cmds (list) – The command names (as strings) for which the help text should be generated

Returns

Formatted help text

Return type

str

abed.help.get_command_help(command)[source]

Generate help text for a command

This function generates the help text for a command that is printed when you call abed help <command>. This command formats the help text similar to the structure of manual pages on Linux. The help text consists of several paragraphs: name, synopsis, description, and optionally a see also and options paragraph. The content of these paragraphs comes from the variables ABED_SHORT_HELP, ABED_SYNOPSES, ABED_LONG_HELP, ABED_SEE_ALSO, and ABED_OPTIONS.

Parameters

command (str) – The command to generate help text for

Returns

Help text formatted appropriately, None if nonexisting command.

Return type

str

abed.help.get_help()[source]

Generate the main help text

Generate the main help text for Abed. This is the help text that is shown with the commands abed help and abed. The help text is modelled on the help text that is shown when you run git without arguments.

Returns

Help text for Abed

Return type

str

abed.help.paragraph_wrapper(all_text, width=70, indent='\t')[source]

Format text to have a maximum length while maintaining paragraphs

This function is very similar to textwrap.wrap(), with the exception that paragraphs in the triple-quoted string will be maintained.

Parameters
  • all_text (str) – Text to format, expected to be a triple-quoted string.

  • width (int, optional) – Maximum width of the formatted text.

  • indent (str, optional) – Indentation of the paragraph in the output.

Returns

Indented formatted paragraphs

Return type

str