This commit is contained in:
Ryan Delaney 2023-07-30 18:17:10 -07:00 committed by GitHub
commit 609ed1cb3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,34 @@
#
# $ terraform destory
#
# Terraform has no command named "destory". Did you mean "destroy"?
#
# $ fuck
# terraform destroy [enter/↑/↓/ctrl+c]
#
import re
from thefuck.utils import for_app
REGEX = (
r"Terraform has no command named \".+?\"\. "
r"Did you mean \"(?P<suggestion>.+)\"\?"
)
@for_app("terraform")
def match(command) -> bool:
return (
"Terraform has no command named" in command.output
and "Did you mean" in command.output
)
def get_new_command(command) -> str:
matches = re.search(REGEX, command.output)
if matches:
return f"""terraform {matches.groupdict().get("suggestion", "")}"""
else:
return ""
enabled_by_default = True