mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 04:21:14 +00:00
Suggest ag -Q
when relevant
This detects when `ag` suggests the `-Q` option, and adds it.
This commit is contained in:
parent
db7dffdb44
commit
db4b37910d
@ -144,6 +144,7 @@ sudo -H pip install thefuck --upgrade
|
|||||||
The Fuck tries to match a rule for the previous command, creates a new command
|
The Fuck tries to match a rule for the previous command, creates a new command
|
||||||
using the matched rule and runs it. Rules enabled by default are as follows:
|
using the matched rule and runs it. Rules enabled by default are as follows:
|
||||||
|
|
||||||
|
* `ag_literal` – adds `-Q` to `ag` when suggested;
|
||||||
* `aws_cli` – fixes misspelled commands like `aws dynamdb scan`
|
* `aws_cli` – fixes misspelled commands like `aws dynamdb scan`
|
||||||
* `cargo` – runs `cargo build` instead of `cargo`;
|
* `cargo` – runs `cargo build` instead of `cargo`;
|
||||||
* `cargo_no_command` – fixes wrongs commands like `cargo buid`;
|
* `cargo_no_command` – fixes wrongs commands like `cargo buid`;
|
||||||
|
25
tests/rules/test_ag_literal.py
Normal file
25
tests/rules/test_ag_literal.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import pytest
|
||||||
|
from thefuck.rules.ag_literal import match, get_new_command
|
||||||
|
from tests.utils import Command
|
||||||
|
|
||||||
|
stderr = ('ERR: Bad regex! pcre_compile() failed at position 1: missing )\n'
|
||||||
|
'If you meant to search for a literal string, run ag with -Q\n')
|
||||||
|
|
||||||
|
matching_command = Command(script='ag \\(', stderr=stderr)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command', [
|
||||||
|
matching_command])
|
||||||
|
def test_match(command):
|
||||||
|
assert match(matching_command)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command', [
|
||||||
|
Command(script='ag foo', stderr='')])
|
||||||
|
def test_not_match(command):
|
||||||
|
assert not match(command)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
|
(matching_command, 'ag -Q \\(')])
|
||||||
|
def test_get_new_command(command, new_command):
|
||||||
|
assert get_new_command(command) == new_command
|
11
thefuck/rules/ag_literal.py
Normal file
11
thefuck/rules/ag_literal.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from thefuck.utils import for_app
|
||||||
|
from thefuck.utils import replace_argument
|
||||||
|
|
||||||
|
|
||||||
|
@for_app('ag')
|
||||||
|
def match(command):
|
||||||
|
return 'run ag with -Q' in command.stderr
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_command(command):
|
||||||
|
return command.script.replace('ag', 'ag -Q', 1)
|
Loading…
x
Reference in New Issue
Block a user