Added secho
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parent e6599a3 · Browse files · 4 files·+27 added−2 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+27 added−2 removed
- other:+27 added−2 removed
Provenance
- Commit
97f942c- Tree
6471626- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
e6599a3
4 files changed+27 added−2 removed
modified:click/__init__.py+2 added-2 removed
31 unmodified lines32 format_filename, get_app_dir33 34 # Terminal functions35 from .termui import prompt, confirm, get_terminal_size, echo_via_pager, \36- progressbar, clear, style, unstyle36+ progressbar, clear, style, unstyle, secho37 38 # Exceptions39 from .exceptions import ClickException, UsageError, BadParameter, \40 FileError, Abort24 unmodified lines65 'get_app_dir',66 67 # Terminal functions68 'prompt', 'confirm', 'get_terminal_size', 'echo_via_pager',69- 'progressbar', 'clear', 'style', 'unstyle',69+ 'progressbar', 'clear', 'style', 'unstyle', 'secho',70 71 # Exceptions72 'ClickException', 'UsageError', 'BadParameter', 'FileError',73 'Abort',10 unmodified linesmodified:click/termui.py+16 added
351 unmodified lines352 353 :param text: the text to remove style information from.354 """355 return strip_ansi(text)356+357+358+def secho(text, file=None, nl=True, **styles):359+ """This function combines :func:`echo` and :func:`style` into one360+ call. As such the following two calls are the same::361+362+ click.secho('Hello World!', fg='green')363+ click.echo(click.style('Hello World!', fg='green'))364+365+ All keyword arguments are forwarded to the underlying functions366+ depending on which one they go with.367+368+ .. versionadded:: 2.0369+ """370+ text = style(text, **styles)371+ return echo(text, file=file, nl=nl)modified:docs/api.rst+2 added
48 unmodified lines49 .. autofunction:: style50 51 .. autofunction:: unstyle52 53+.. autofunction:: secho54+55 .. autofunction:: format_filename56 57 .. autofunction:: get_terminal_size58 101 unmodified linesmodified:docs/utils.rst+7 added
65 unmodified lines66 click.echo(click.style('Hello World!', fg='green'))67 click.echo(click.style('Some more text', bg='blue', fg='white'))68 click.echo(click.style('ATTENTION', blink=True))69 70+The combination of :func:`echo` and :func:`style` is also available in71+a single function called :func:`secho`::72 73+ click.secho('Hello World!', fg='green')74+ click.secho('Some more text', bg='blue', fg='white')75+ click.secho('ATTENTION', blink=True)76+77+78 .. _colorama: https://pypi.python.org/pypi/colorama79 80 81 Screen Clearing131 unmodified lines