CLI utilities - tmuxp.cli.utils

CLI utility helpers for tmuxp.

tmuxp.cli.utils.tmuxp_echo(message=None, log_level='INFO', style_log=False)[source]

Combine logging.log and click.echo.

Return type:

None

tmuxp.cli.utils.prompt(name, default=None, value_proc=None)[source]

Return user input from command line.

Return type:

str

Parameters:
  • name – prompt text

  • default – default value if no input provided.

Return type:

str

tmuxp.cli.utils.prompt_bool(name, default=False, yes_choices=None, no_choices=None)[source]

Return True / False by prompting user input from command line.

Return type:

bool

Parameters:
  • name – prompt text

  • default – default value if no input provided.

  • yes_choices – default ‘y’, ‘yes’, ‘1’, ‘on’, ‘true’, ‘t’

  • no_choices – default ‘n’, ‘no’, ‘0’, ‘off’, ‘false’, ‘f’

Return type:

bool

tmuxp.cli.utils.prompt_yes_no(name, default=True)[source]

prompt_bool() returning yes by default.

Return type:

bool

tmuxp.cli.utils.prompt_choices(name, choices, default=None, no_choice=('none',))[source]

Return user input from command line from set of provided choices.

Return type:

Optional[str]

Parameters:
  • name – prompt text

  • choices – list or tuple of available choices. Choices may be single strings or (key, value) tuples.

  • default – default value if no input provided.

  • no_choice – acceptable list of strings for “null choice”

Return type:

str

tmuxp.cli.utils.strip_ansi(value)[source]

Clear ANSI from a string value.

Return type:

str

tmuxp.cli.utils._interpret_color(color, offset=0)[source]
Return type:

str

exception tmuxp.cli.utils.UnknownStyleColor(color, *args, **kwargs)[source]

Bases: Exception

Raised when encountering an unknown terminal style color.

tmuxp.cli.utils.style(text, fg=None, bg=None, bold=None, dim=None, underline=None, overline=None, italic=None, blink=None, reverse=None, strikethrough=None, reset=True)[source]

Credit: click.

Return type:

str

tmuxp.cli.utils.unstyle(text)[source]

Remove ANSI styling information from a string.

Usually it’s not necessary to use this function as tmuxp_echo function will automatically remove styling if necessary.

Credit: click.

text : the text to remove style information from.

Return type:

str