#960: Improve pacman_invalid_option rule (#1072)

The rule now matches all possible lower case options and only those, not
failing for those that cannot be fixed.
This commit is contained in:
Pablo Aguiar
2020-04-06 21:46:40 +02:00
committed by GitHub
parent 3c542a5b8c
commit 6975d30818
2 changed files with 30 additions and 15 deletions
+9 -3
View File
@@ -1,14 +1,20 @@
from thefuck.specific.archlinux import archlinux_env
from thefuck.specific.sudo import sudo_support
from thefuck.utils import for_app
import re
@sudo_support
@for_app("pacman")
def match(command):
return "error: invalid option '-s'" in command.output
return command.output.startswith("error: invalid option '-") and any(
" -{}".format(option) in command.script for option in "surqfdvt"
)
def get_new_command(command):
opt = re.findall(r" -[dqrstuf]", command.script)[0]
return re.sub(opt, opt.upper(), command.script)
option = re.findall(r" -[dfqrstuv]", command.script)[0]
return re.sub(option, option.upper(), command.script)
enabled_by_default = archlinux_env()