hydraclick.terminal_effects#
Functions#
Check if terminal effects should be disabled by looking at environment variables. |
|
|
Configure terminal effects such as print speed and gradient colors. |
|
Remove the last num_lines lines printed in the terminal. |
|
Calculate the number of lines the given text will take when wrapped in the terminal. |
|
Display a terminal effect animation for a given text. |
|
Patch the Click parse_args function to display a terminal effect. |
|
Patch the Click get_help_option function to display a terminal effect for the help option. |
|
Set a terminal effect animation for displaying help in Click commands. |
Module Contents#
- hydraclick.terminal_effects.get_no_terminal_effects()[source]#
Check if terminal effects should be disabled by looking at environment variables.
This function checks the environment variables OMEGACLICK_NO_TERMINAL_EFFECTS and NO_TERMINAL_EFFECTS to determine if terminal effects should be disabled. If no environment variable is set, it returns False.
- Returns:
True if terminal effects should be disabled, False otherwise.
- Return type:
bool
Example
>>> os.environ["NO_TERMINAL_EFFECTS"] = "true" >>> get_no_terminal_effects() True
- hydraclick.terminal_effects.config_effect(effect)[source]#
Configure terminal effects such as print speed and gradient colors.
This function adjusts the terminal effect’s configuration, such as print speed, return speed, and gradient colors for rendering.
- Parameters:
effect – The terminal effect object to be configured.
- Returns:
The modified terminal effect object.
Example
>>> effect = SomeEffect() >>> config_effect(effect) <configured effect>
- hydraclick.terminal_effects.remove_lines(num_lines)[source]#
Remove the last num_lines lines printed in the terminal.
This function sends ANSI escape codes to move the terminal cursor up and clear the last num_lines lines from the terminal.
- Parameters:
num_lines (int) – The number of lines to remove.
Example
>>> remove_lines(3) # Removes the last 3 printed lines
- hydraclick.terminal_effects.count_wrapped_lines(text, terminal_width)[source]#
Calculate the number of lines the given text will take when wrapped in the terminal.
- Parameters:
text (str) – The text to be wrapped.
terminal_width (int) – The width of the terminal in characters.
- Returns:
The number of lines the text will occupy in the terminal.
- Return type:
int
Example
>>> count_wrapped_lines("This is a long line of text.", 10) 3
- hydraclick.terminal_effects.display_terminal_effect(value, effect_cls=None)[source]#
Display a terminal effect animation for a given text.
This function displays a text-based terminal effect using the provided effect class. The effect is rendered with custom configurations, and once the animation is complete, the effect is cleaned up from the terminal.
- Parameters:
value (str) – The text to display with the terminal effect.
effect_cls (optional) – The class of the terminal effect to use. Defaults to Print.
Example
>>> display_terminal_effect("Hello World!")
- hydraclick.terminal_effects.patch_parse_args(terminal_effect)[source]#
Patch the Click parse_args function to display a terminal effect.
This function overrides the parse_args method of Click’s MultiCommand to display a custom terminal effect for the help message when no arguments are passed.
- Parameters:
terminal_effect (Callable) – A callable that renders the terminal effect.
Example
>>> patch_parse_args(display_terminal_effect)
- hydraclick.terminal_effects.patch_get_help_option(terminal_effect)[source]#
Patch the Click get_help_option function to display a terminal effect for the help option.
This function overrides Click’s get_help_option method to display a terminal effect whenever the help message is requested.
- Parameters:
terminal_effect (Callable) – A callable that renders the terminal effect.
Example
>>> patch_get_help_option(display_terminal_effect)
- hydraclick.terminal_effects.set_terminal_effect(terminal_effect)[source]#
Set a terminal effect animation for displaying help in Click commands.
This function applies a patch to the Click parse_args and get_help_option methods, so the help message is displayed with the specified terminal effect.
- Parameters:
terminal_effect (Callable) – A callable that renders the terminal effect.
Example
>>> set_terminal_effect(display_terminal_effect)