mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
Adding rule for trying to search using apt-get
This commit is contained in:
parent
5ab2cf646e
commit
2b3e8dc62a
@ -206,6 +206,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
|
|||||||
Enabled by default only on specific platforms:
|
Enabled by default only on specific platforms:
|
||||||
|
|
||||||
* `apt_get` – installs app from apt if it not installed;
|
* `apt_get` – installs app from apt if it not installed;
|
||||||
|
* `apt_get_search` – changes trying to search using `apt-get` with searching using `apt-cache`
|
||||||
* `brew_install` – fixes formula name for `brew install`;
|
* `brew_install` – fixes formula name for `brew install`;
|
||||||
* `brew_unknown_command` – fixes wrong brew commands, for example `brew docto/brew doctor`;
|
* `brew_unknown_command` – fixes wrong brew commands, for example `brew docto/brew doctor`;
|
||||||
* `brew_upgrade` – appends `--all` to `brew upgrade` as per Homebrew's new behaviour;
|
* `brew_upgrade` – appends `--all` to `brew upgrade` as per Homebrew's new behaviour;
|
||||||
|
20
tests/rules/test_apt_get_search.py
Normal file
20
tests/rules/test_apt_get_search.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import pytest
|
||||||
|
from thefuck.rules.apt_get_search import get_new_command, match
|
||||||
|
from tests.utils import Command
|
||||||
|
|
||||||
|
|
||||||
|
def test_match():
|
||||||
|
assert match(Command('apt-get search foo'), None)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command', [
|
||||||
|
Command('apt-cache search foo'),
|
||||||
|
Command('aptitude search foo'),
|
||||||
|
Command('apt search foo')
|
||||||
|
])
|
||||||
|
def test_not_match(command):
|
||||||
|
assert not match(command, None)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_new_command():
|
||||||
|
assert get_new_command(Command('apt-get search foo'), None) == 'apt-cache search foo'
|
9
thefuck/rules/apt_get_search.py
Normal file
9
thefuck/rules/apt_get_search.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def match(command, settings):
|
||||||
|
return command.script.startswith('apt-get search')
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_command(command, settings):
|
||||||
|
return re.sub(r'^apt-get', 'apt-cache', command.script)
|
Loading…
x
Reference in New Issue
Block a user