Add brew_reinstall rule (#816)

Replaces install with reinstall when a package is already installed.
This commit is contained in:
Iulian Onofrei
2018-05-22 20:25:05 +03:00
committed by Vladimir Iakovlev
parent f6e50bef82
commit 89207d6d7c
3 changed files with 48 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import re
from thefuck.utils import for_app
warning_regex = re.compile(r'Warning: (?:.(?!is ))+ is already installed and '
r'up-to-date')
message_regex = re.compile(r'To reinstall (?:(?!, ).)+, run `brew reinstall '
r'[^`]+`')
@for_app('brew', at_least=2)
def match(command):
return ('install' in command.script
and warning_regex.search(command.output)
and message_regex.search(command.output))
def get_new_command(command):
return command.script.replace('install', 'reinstall')