Skip to content

Commit

Permalink
Merge branch 'her0e1c1-fix-secho'
Browse files Browse the repository at this point in the history
Fix #424
  • Loading branch information
untitaker committed Apr 8, 2016
2 parents cdea8fc + 70f29dc commit 2899795
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Version 7.0
- The exception objects now store unicode properly.
- Added the ability to hide commands and options from help.
- Added Float Range in Types.
- `secho`'s first argument can now be `None`, like in `echo`.

Version 6.5
-----------
Expand Down
6 changes: 4 additions & 2 deletions click/termui.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def unstyle(text):
return strip_ansi(text)


def secho(text, file=None, nl=True, err=False, color=None, **styles):
def secho(message=None, file=None, nl=True, err=False, color=None, **styles):
"""This function combines :func:`echo` and :func:`style` into one
call. As such the following two calls are the same::
Expand All @@ -417,7 +417,9 @@ def secho(text, file=None, nl=True, err=False, color=None, **styles):
.. versionadded:: 2.0
"""
return echo(style(text, **styles), file=file, nl=nl, err=err, color=color)
if message is not None:
message = style(message, **styles)
return echo(message, file=file, nl=nl, err=err, color=color)


def edit(text=None, editor=None, env=None, require_save=True,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_termui.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ def cli():
monkeypatch.setattr(click._termui_impl, 'isatty', lambda _: True)
result = runner.invoke(cli, [])
assert result.exception is None


def test_secho(runner):
with runner.isolation() as out:
click.secho(None, nl=False)
bytes = out.getvalue()
assert bytes == b''

0 comments on commit 2899795

Please sign in to comment.