pofff.utils.terminal module#

Format command-line messages for pofff.

ANSI colors are applied when supported by the selected stream. The module provides consistent formatting for invalid, accepted, deprecated, and informational values, plus fatal errors, warnings, tips, progress messages, and generated-file reports.

pofff.utils.terminal._colorize(text: str, code: str, stream: object = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>) str[source]#

Wrap text in an ANSI color sequence when supported.

Parameters:
textstr

Text to format.

codestr

ANSI Select Graphic Rendition code.

streamobject, optional

Output stream used to determine ANSI-color support.

Returns:
str

Colored text, or unchanged text when colors are disabled.

pofff.utils.terminal._supports_color(stream: object = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>) bool[source]#

Check whether an output stream supports ANSI colors.

Parameters:
streamobject, optional

Output stream used to determine ANSI-color support.

Returns:
bool

Whether ANSI color output is enabled for the stream.

pofff.utils.terminal.cli_correct_value(value: str) str[source]#

Format a correct CLI option or value.

Parameters:
valuestr

Value to inspect or format.

Returns:
str

Quoted value colored as a valid alternative when supported.

pofff.utils.terminal.cli_error_value(value: str) str[source]#

Format an invalid CLI option or value.

Parameters:
valuestr

Value to inspect or format.

Returns:
str

Quoted value colored as invalid when supported.

pofff.utils.terminal.cli_info_value(value: str) str[source]#

Format an informational CLI option or value.

Parameters:
valuestr

Value to inspect or format.

Returns:
str

Quoted value colored as information when supported.

pofff.utils.terminal.cli_warning_value(value: str) str[source]#

Format a deprecated CLI option or value.

Parameters:
valuestr

Value to inspect or format.

Returns:
str

Quoted value colored as a warning when supported.

pofff.utils.terminal.pofff_error(message: str) NoReturn[source]#

Raise a fatal command-line error.

Parameters:
messagestr

Human-readable message to display or append.

Raises:
SystemExit

Always raised with the formatted error message.

pofff.utils.terminal.pofff_info(message: str) None[source]#

Display an informational command-line message.

Parameters:
messagestr

Human-readable message to display or append.

pofff.utils.terminal.pofff_name(stream: object = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>) str[source]#

Format the pofff program name.

Parameters:
streamobject, optional

Output stream used to determine ANSI-color support.

Returns:
str

Formatted program name.

pofff.utils.terminal.pofff_success(msg: str, output_dir: str, filenames: list[str]) None[source]#

Display the generated output location and filenames.

Parameters:
msgstr

Optional success text printed before the output location.

output_dirstr

Directory containing the generated files.

filenameslist[str]

Generated filenames to report.

pofff.utils.terminal.pofff_tip(message: str) None[source]#

Display a command-line suggestion.

Parameters:
messagestr

Human-readable message to display or append.

pofff.utils.terminal.pofff_warning(message: str) None[source]#

Display a non-fatal command-line warning.

Parameters:
messagestr

Human-readable message to display or append.