From a734b94fece18bbd07f5da0850cdd7211b4bf520 Mon Sep 17 00:00:00 2001 From: Joseph Frazier <1212jtraceur@gmail.com> Date: Thu, 29 Sep 2016 17:19:16 -0400 Subject: [PATCH] Suggest `brew uninstall --force` when relevant Resolves https://github.com/nvbn/thefuck/issues/553 --- README.md | 1 + thefuck/rules/brew_uninstall.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 thefuck/rules/brew_uninstall.py diff --git a/README.md b/README.md index 254f2b2..162dd8d 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,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 ` into `brew upgrade `; * `brew_upgrade` – appends `--all` to `brew upgrade` as per Homebrew's new behaviour; diff --git a/thefuck/rules/brew_uninstall.py b/thefuck/rules/brew_uninstall.py new file mode 100644 index 0000000..d2306ab --- /dev/null +++ b/thefuck/rules/brew_uninstall.py @@ -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)