1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-04-15 07:10:52 +01:00
thefuck/thefuck/rules/unknown_command.py

14 lines
462 B
Python

import re
from thefuck.utils import replace_command
def match(command):
return (re.search(r"([^:]*): Unknown command.*", command.stderr) != None
and re.search(r"Did you mean ([^?]*)?", command.stderr) != None)
def get_new_command(command):
broken_cmd = re.findall(r"([^:]*): Unknown command.*", command.stderr)[0]
matched = re.findall(r"Did you mean ([^?]*)?", command.stderr)
return replace_command(command, broken_cmd, matched)