From 7b44c3d2f26fb3898b0562ad9286a826a1671f09 Mon Sep 17 00:00:00 2001 From: Ronan Doolan Date: Sat, 9 May 2020 16:21:55 +0100 Subject: [PATCH] Set number of blank lines as two --- tests/rules/test_gcloud_cli.py | 3 +++ thefuck/rules/gcloud_cli.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tests/rules/test_gcloud_cli.py b/tests/rules/test_gcloud_cli.py index ba430c4d..6de4829a 100644 --- a/tests/rules/test_gcloud_cli.py +++ b/tests/rules/test_gcloud_cli.py @@ -37,15 +37,18 @@ To search the help text of gcloud commands, run: gcloud help -- SEARCH_TERMS ''' + @pytest.mark.parametrize('command', [ Command('gcloud comute', misspelled_command), Command('gcloud compute instance list', misspelled_subcommand)]) def test_match(command): assert match(command) + def test_not_match(): assert not match(Command('aws dynamodb invalid', no_suggestions)) + @pytest.mark.parametrize('command, result', [ (Command('gcloud comute', misspelled_command), ['gcloud compute instances list']), diff --git a/thefuck/rules/gcloud_cli.py b/thefuck/rules/gcloud_cli.py index 8d204c10..035df5df 100644 --- a/thefuck/rules/gcloud_cli.py +++ b/thefuck/rules/gcloud_cli.py @@ -5,10 +5,12 @@ from thefuck.utils import for_app, replace_argument INVALID_CHOICE = "(?<=Invalid choice: ')(.*)(?=', maybe you meant:)" OPTIONS = "^\\s*\\*\\s(.*)" + @for_app('gcloud') def match(command): return "usage:" in command.output and "maybe you meant:" in command.output + def get_new_command(command): mistake = re.search(INVALID_CHOICE, command.output).group(0) options = re.findall(OPTIONS, command.output, flags=re.MULTILINE)