tmuxp formatter - tmuxp.cli._formatter¶
Custom help formatter for tmuxp CLI with colorized examples.
This module provides a custom argparse formatter that colorizes example sections in help output, similar to vcspull’s formatter.
Examples
>>> from tmuxp.cli._formatter import TmuxpHelpFormatter
>>> TmuxpHelpFormatter
<class '...TmuxpHelpFormatter'>
-
class tmuxp.cli._formatter.TmuxpHelpFormatter¶class tmuxp.cli._formatter.TmuxpHelpFormatter¶
Bases:
RawDescriptionHelpFormatterHelp formatter with colorized examples for tmuxp CLI.
This formatter extends RawDescriptionHelpFormatter to preserve formatting of description text while adding syntax highlighting to example sections.
The formatter uses a _theme attribute (set externally) to apply colors. If no theme is set, the formatter falls back to plain text output.
Examples
>>> formatter = TmuxpHelpFormatter("tmuxp") >>> formatter <...TmuxpHelpFormatter object at ...>
-
class tmuxp.cli._formatter.HelpTheme¶class tmuxp.cli._formatter.HelpTheme¶
Bases:
NamedTupleTheme colors for help output.
Examples
>>> from tmuxp.cli._formatter import HelpTheme >>> theme = HelpTheme.from_colors(None) >>> theme.reset ''
-
tmuxp.cli._formatter.create_themed_formatter(colors=None)¶tmuxp.cli._formatter.create_themed_formatter(colors=None)¶
Create a help formatter class with theme bound.
This factory creates a formatter subclass with the theme injected, allowing colorized help output without modifying argparse internals.
When no colors argument is provided, uses AUTO mode which respects NO_COLOR, FORCE_COLOR environment variables and TTY detection.
Examples
>>> from tmuxp.cli._colors import ColorMode, Colors >>> from tmuxp.cli._formatter import create_themed_formatter, HelpTheme
With explicit colors enabled:
>>> colors = Colors(ColorMode.ALWAYS) >>> formatter_cls = create_themed_formatter(colors) >>> formatter = formatter_cls("test") >>> formatter._theme is not None True
With colors disabled:
>>> colors = Colors(ColorMode.NEVER) >>> formatter_cls = create_themed_formatter(colors) >>> formatter = formatter_cls("test") >>> formatter._theme is None True