mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 09:39:01 +00:00
Merge f13d47b4a011dffb7438a3be4968906cd76cd23c into c7e7e1d884d3bb241ea6448f72a989434c2a35ec
This commit is contained in:
commit
0982ab27a0
37
thefuck/rules/pamac_invalid_operation.py
Normal file
37
thefuck/rules/pamac_invalid_operation.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import subprocess
|
||||||
|
from thefuck.utils import for_app, eager, replace_command
|
||||||
|
|
||||||
|
@for_app('pamac')
|
||||||
|
def match(command):
|
||||||
|
return "Available actions:" in command.output
|
||||||
|
|
||||||
|
|
||||||
|
@eager
|
||||||
|
def _parse_pamac_operations(help_text_lines):
|
||||||
|
is_commands_list = False
|
||||||
|
for line in help_text_lines:
|
||||||
|
line = line.decode().strip()
|
||||||
|
if is_commands_list and line:
|
||||||
|
yield line.split()[1].split(',')[0]
|
||||||
|
elif line.startswith('Available actions:'):
|
||||||
|
is_commands_list = True
|
||||||
|
|
||||||
|
def _get_operations(app):
|
||||||
|
proc = subprocess.Popen([app, '--help'],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
lines = proc.stdout.readlines()
|
||||||
|
|
||||||
|
if app == 'pamac':
|
||||||
|
return _parse_pamac_operations(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_command(command):
|
||||||
|
invalid_operation = command.script.split()[1]
|
||||||
|
|
||||||
|
if invalid_operation == 'uninstall':
|
||||||
|
return [command.script.replace('uninstall', 'remove')]
|
||||||
|
|
||||||
|
else:
|
||||||
|
operations = _get_operations(command.script_parts[0])
|
||||||
|
return replace_command(command, invalid_operation, operations)
|
Loading…
x
Reference in New Issue
Block a user