mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
Merge pull request #555 from josephfrazier/brew-uninstall-force
Suggest `brew uninstall --force` when relevant
This commit is contained in:
commit
5d3a727d1a
@ -239,6 +239,7 @@ Enabled by default only on specific platforms:
|
||||
* `apt_get_search` – changes trying to search using `apt-get` with searching using `apt-cache`;
|
||||
* `apt_invalid_operation` – fixes invalid `apt` and `apt-get` calls, like `apt-get isntall vim`;
|
||||
* `brew_install` – fixes formula name for `brew install`;
|
||||
* `brew_uninstall` – adds `--force` to `brew uninstall` if multiple versions were installed;
|
||||
* `brew_unknown_command` – fixes wrong brew commands, for example `brew docto/brew doctor`;
|
||||
* `brew_update_formula` – turns `brew update <formula>` into `brew upgrade <formula>`;
|
||||
* `brew_upgrade` – appends `--all` to `brew upgrade` as per Homebrew's new behaviour;
|
||||
|
31
tests/rules/test_brew_uninstall.py
Normal file
31
tests/rules/test_brew_uninstall.py
Normal file
@ -0,0 +1,31 @@
|
||||
import pytest
|
||||
from tests.utils import Command
|
||||
from thefuck.rules.brew_uninstall import get_new_command, match
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def stdout():
|
||||
return ("Uninstalling /usr/local/Cellar/tbb/4.4-20160916... (118 files, 1.9M)\n"
|
||||
"tbb 4.4-20160526, 4.4-20160722 are still installed.\n"
|
||||
"Remove all versions with `brew uninstall --force tbb`.\n")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def new_command(formula):
|
||||
return 'brew uninstall --force {}'.format(formula)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('script', ['brew uninstall tbb', 'brew rm tbb', 'brew remove tbb'])
|
||||
def test_match(stdout, script):
|
||||
assert match(Command(script=script, stdout=stdout))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('script', ['brew remove gnuplot'])
|
||||
def test_not_match(script):
|
||||
stdout='Uninstalling /usr/local/Cellar/gnuplot/5.0.4_1... (44 files, 2.3M)\n'
|
||||
assert not match(Command(script=script, stdout=stdout))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('script, formula, ', [('brew uninstall tbb', 'tbb')])
|
||||
def test_get_new_command(stdout, new_command, script, formula):
|
||||
assert get_new_command(Command(script=script, stdout=stdout)) == new_command
|
13
thefuck/rules/brew_uninstall.py
Normal file
13
thefuck/rules/brew_uninstall.py
Normal file
@ -0,0 +1,13 @@
|
||||
from thefuck.utils import for_app
|
||||
|
||||
|
||||
@for_app('brew', at_least=2)
|
||||
def match(command):
|
||||
return (command.script_parts[1] in ['uninstall', 'rm', 'remove']
|
||||
and "brew uninstall --force" in command.stdout)
|
||||
|
||||
|
||||
def get_new_command(command):
|
||||
command.script_parts[1] = 'uninstall'
|
||||
command.script_parts.insert(2, '--force')
|
||||
return ' '.join(command.script_parts)
|
Loading…
x
Reference in New Issue
Block a user