2019-07-31 05:10:28 +00:00
|
|
|
import sys
|
|
|
|
from difflib import SequenceMatcher
|
|
|
|
import logger
|
|
|
|
from . import arguments
|
|
|
|
|
2019-08-29 22:17:47 +00:00
|
|
|
def recommend(print_default: bool = True):
|
2019-07-31 05:10:28 +00:00
|
|
|
tried = sys.argv[1]
|
|
|
|
args = arguments.get_arguments()
|
|
|
|
print_message = 'Command not found:'
|
|
|
|
for key in args.keys():
|
|
|
|
for word in key:
|
|
|
|
if SequenceMatcher(None, tried, word).ratio() >= 0.75:
|
|
|
|
logger.warn('%s "%s", did you mean "%s"?' % (print_message, tried, word), terminal=True)
|
|
|
|
return
|
2019-08-29 22:17:47 +00:00
|
|
|
if print_default: logger.error('%s "%s"' % (print_message, tried), terminal=True)
|