From 2c1666abc43f2a2c580d9e3128655ab74eb0e4dd Mon Sep 17 00:00:00 2001 From: Pablo Santiago Blum de Aguiar Date: Sat, 18 Jun 2016 13:50:47 -0300 Subject: [PATCH 1/2] #N/A: Update cargo_no_command rule to support current Cargo --- tests/rules/test_cargo_no_command.py | 13 ++++++++++--- thefuck/rules/cargo_no_command.py | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/rules/test_cargo_no_command.py b/tests/rules/test_cargo_no_command.py index 2c70b6b..53eea0b 100644 --- a/tests/rules/test_cargo_no_command.py +++ b/tests/rules/test_cargo_no_command.py @@ -3,19 +3,26 @@ from thefuck.rules.cargo_no_command import match, get_new_command from tests.utils import Command -no_such_subcommand = """No such subcommand +no_such_subcommand_old = """No such subcommand Did you mean `build`? """ +no_such_subcommand = """error: no such subcommand + +\tDid you mean `build`? +""" + @pytest.mark.parametrize('command', [ - Command(script='cargo buid', stderr=no_such_subcommand)]) + Command(script='cargo buid', stderr=no_such_subcommand_old), + Command(script='cargo buils', stderr=no_such_subcommand)]) def test_match(command): assert match(command) @pytest.mark.parametrize('command, new_command', [ - (Command('cargo buid', stderr=no_such_subcommand), 'cargo build')]) + (Command('cargo buid', stderr=no_such_subcommand_old), 'cargo build'), + (Command('cargo buils', stderr=no_such_subcommand), 'cargo build')]) def test_get_new_command(command, new_command): assert get_new_command(command) == new_command diff --git a/thefuck/rules/cargo_no_command.py b/thefuck/rules/cargo_no_command.py index 02e2a7f..c34325e 100644 --- a/thefuck/rules/cargo_no_command.py +++ b/thefuck/rules/cargo_no_command.py @@ -4,7 +4,7 @@ from thefuck.utils import replace_argument, for_app @for_app('cargo', at_least=1) def match(command): - return ('No such subcommand' in command.stderr + return ('o such subcommand' in command.stderr and 'Did you mean' in command.stderr) From 3893e0cdca64616e059b704c640ee5ea33a9d884 Mon Sep 17 00:00:00 2001 From: nvbn Date: Tue, 28 Jun 2016 15:50:41 +0300 Subject: [PATCH 2/2] #517: Little refactoring --- thefuck/rules/cargo_no_command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thefuck/rules/cargo_no_command.py b/thefuck/rules/cargo_no_command.py index c34325e..f141b67 100644 --- a/thefuck/rules/cargo_no_command.py +++ b/thefuck/rules/cargo_no_command.py @@ -4,7 +4,7 @@ from thefuck.utils import replace_argument, for_app @for_app('cargo', at_least=1) def match(command): - return ('o such subcommand' in command.stderr + return ('no such subcommand' in command.stderr.lower() and 'Did you mean' in command.stderr)