mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 02:01:13 +00:00
Change the message when expecting side effect
The previous behavior is really surprising: ``` some_command* [enter/ctrl+c] |<~~~~~~~~~~~>|<~~~~~~~~~~~~>| | bold text | normal weight| ``` as if the '*' is part of the command to be executed. The new behavior is: ``` some_command (+side effect) [enter/ctrl+c] |<~~~~~~~~~~>|<~~~~~~~~~~~~~~~~~~~~~~~~~~~>| | bold text | normal weight | ```
This commit is contained in:
parent
1c5fef3a34
commit
3173ef10c6
@ -153,7 +153,7 @@ class TestConfirm(object):
|
||||
|
||||
def test_with_side_effect_and_without_confirmation(self, capsys):
|
||||
assert main.confirm('command', Mock(), Mock(require_confirmation=False))
|
||||
assert capsys.readouterr() == ('', 'command*\n')
|
||||
assert capsys.readouterr() == ('', 'command (+side effect)\n')
|
||||
|
||||
# `stdin` fixture should be applied after `capsys`
|
||||
def test_when_confirmation_required_and_confirmed(self, capsys, stdin):
|
||||
@ -165,7 +165,7 @@ class TestConfirm(object):
|
||||
def test_when_confirmation_required_and_confirmed_with_side_effect(self, capsys, stdin):
|
||||
assert main.confirm('command', Mock(), Mock(require_confirmation=True,
|
||||
no_colors=True))
|
||||
assert capsys.readouterr() == ('', 'command* [enter/ctrl+c]')
|
||||
assert capsys.readouterr() == ('', 'command (+side effect) [enter/ctrl+c]')
|
||||
|
||||
def test_when_confirmation_required_and_aborted(self, capsys, stdin):
|
||||
stdin.side_effect = KeyboardInterrupt
|
||||
|
@ -29,19 +29,19 @@ def rule_failed(rule, exc_info, settings):
|
||||
|
||||
|
||||
def show_command(new_command, side_effect, settings):
|
||||
sys.stderr.write('{bold}{command}{side_effect}{reset}\n'.format(
|
||||
sys.stderr.write('{bold}{command}{reset}{side_effect}\n'.format(
|
||||
command=new_command,
|
||||
side_effect='*' if side_effect else '',
|
||||
side_effect=' (+side effect)' if side_effect else '',
|
||||
bold=color(colorama.Style.BRIGHT, settings),
|
||||
reset=color(colorama.Style.RESET_ALL, settings)))
|
||||
|
||||
|
||||
def confirm_command(new_command, side_effect, settings):
|
||||
sys.stderr.write(
|
||||
'{bold}{command}{side_effect}{reset} '
|
||||
'{bold}{command}{reset}{side_effect} '
|
||||
'[{green}enter{reset}/{red}ctrl+c{reset}]'.format(
|
||||
command=new_command,
|
||||
side_effect='*' if side_effect else '',
|
||||
side_effect=' (+side effect)' if side_effect else '',
|
||||
bold=color(colorama.Style.BRIGHT, settings),
|
||||
green=color(colorama.Fore.GREEN, settings),
|
||||
red=color(colorama.Fore.RED, settings),
|
||||
|
Loading…
x
Reference in New Issue
Block a user