xnano.cli.help
xnano.cli.help
¶
xnano.cli.help
Format command help and user-facing errors for terminals and plain-text streams.
Functions:
-
should_use_styled_help–Return whether styled help should be attempted.
-
format_plain_help–Build deterministic plain-text help for
command. -
render_help–Render help for
command, optionally via terminal components. -
print_error–Print an error (and optional help) to stderr.
should_use_styled_help
¶
Return whether styled help should be attempted.
Parameters:
-
stream(TextIO | None, default:None) –Output stream (defaults to stdout).
Returns:
-
bool–Truewhen a live color-capable TTY is available.
Source code in xnano/cli/help.py
format_plain_help
¶
format_plain_help(command: 'Command') -> str
Build deterministic plain-text help for command.
Parameters:
-
command('Command') –Command whose help should be rendered.
Returns:
-
str–Help text ending with a newline when non-empty.
Source code in xnano/cli/help.py
render_help
¶
Render help for command, optionally via terminal components.
Parameters:
-
command('Command') –Command to document.
-
stream(TextIO | None, default:None) –Unused except for TTY detection.
Returns:
-
str–Help text. Styled rendering falls back to plain text when the
-
str–terminal path is unavailable.
Source code in xnano/cli/help.py
print_error
¶
print_error(
message: str,
command: "Command | None" = None,
*,
file: TextIO | None = None
) -> None
Print an error (and optional help) to stderr.