plopm.utils.terminal module#

Format plopm help text and command-line messages.

The module hides deprecated aliases from --help, reports their replacements, and applies ANSI colors only when supported by the selected output stream.

class PlopmHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None, color=True)[source]#

Bases: ArgumentDefaultsHelpFormatter

Argparse formatter that hides deprecated option aliases.

Current options retain the standard argparse.ArgumentDefaultsHelpFormatter layout and default values.

Methods

add_argument

add_arguments

add_text

add_usage

end_section

format_help

start_section

warn_deprecated_options(argv)[source]#

Warn once for each deprecated option in an argument list.

Parameters:
argvSequence[str]

Command-line arguments, excluding or including the executable name.

Parameters:

argv (Sequence[str])

Return type:

None

cli_deprecated_value(value)[source]#

Format a deprecated CLI option or value.

Parameters:
valuestr

Option or value to display.

Returns:
str

Quoted value with deprecated-option styling when supported.

Parameters:

value (str)

Return type:

str

cli_current_value(value)[source]#

Format a current CLI option or value.

Parameters:
valuestr

Option or value to display.

Returns:
str

Quoted value with current-option styling when supported.

Parameters:

value (str)

Return type:

str

cli_error_value(value)[source]#

Format an invalid CLI option or value.

Parameters:
valuestr

Option or value to display.

Returns:
str

Quoted value with error styling when supported.

Parameters:

value (str)

Return type:

str

cli_info_value(value)[source]#

Format an informational CLI option or value.

Parameters:
valuestr

Option or value to display.

Returns:
str

Quoted value with informational styling when supported.

Parameters:

value (str)

Return type:

str

plopm_error(message)[source]#

Raise a fatal command-line error.

Parameters:
messagestr

Error message displayed after the plopm label.

Raises:
SystemExit

Always raised with the formatted error message.

Parameters:

message (str)

Return type:

NoReturn

plopm_warning(message)[source]#

Display a non-fatal command-line warning.

Parameters:
messagestr

Warning message displayed on standard error.

Parameters:

message (str)

Return type:

None

plopm_info(message)[source]#

Display an informational command-line message.

Parameters:
messagestr

Message displayed on standard output.

Parameters:

message (str)

Return type:

None

plopm_tip(message)[source]#

Display a command-line suggestion.

Parameters:
messagestr

Suggestion displayed on standard output.

Parameters:

message (str)

Return type:

None

plopm_success(output_dir, filenames)[source]#

Display the generated output location and filenames.

Parameters:
output_dirstr

Directory containing the generated files.

filenameslist[str]

Generated filenames.

Parameters:
Return type:

None

plopm_name(stream=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]#

Format the plopm program name.

Parameters:
streamobject, default: sys.stderr

Output stream used to determine color support.

Returns:
str

Program name with gradient colors when supported.

Parameters:

stream (object)

Return type:

str