1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-03 17:28:58 +00:00
thefuck/thefuck/rules/aws_cli.py
JordonPhillips 7bf405e9c3 Add aws cli rule
This rule corrects spelling mistakes for aws cli commands and
subcommands.
2016-09-29 14:22:08 -07:00

18 lines
517 B
Python

import re
from thefuck.utils import for_app, replace_argument
INVALID_CHOICE = "(?<=Invalid choice: ')(.*)(?=', maybe you meant:)"
OPTIONS = "^\s*\*\s(.*)"
@for_app('aws')
def match(command):
return "usage:" in command.stderr and "maybe you meant:" in command.stderr
def get_new_command(command):
mistake = re.search(INVALID_CHOICE, command.stderr).group(0)
options = re.findall(OPTIONS, command.stderr, flags=re.MULTILINE)
return [replace_argument(command.script, mistake, o) for o in options]