1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 06:38:32 +00:00

added confirmation function in logs.py and changed fix_command so that it calls the confirmation functin in logs for reboot

This commit is contained in:
ICalhoun 2021-04-05 14:44:57 -04:00
parent 488b8ca6ab
commit 6f99e2ea7f
3 changed files with 16 additions and 5 deletions

View File

@ -41,12 +41,11 @@ def fix_command(known_args):
corrected_commands = get_corrected_commands(command)
selected_command = select_command(corrected_commands)
confirmation = True
if selected_command.script == "reboot":
confirmation = confirm_command("Reboot System?")
if selected_command and confirmation:
selected_command.run(command)
else:

View File

@ -139,3 +139,14 @@ def version(thefuck_version, python_version, shell_info):
u'The Fuck {} using Python {} and {}\n'.format(thefuck_version,
python_version,
shell_info))
def confirmation(confirm):
if confirm is True:
sys.stderr.write(u"\n{bold}System Rebooting!\n{reset}".format(
bold=color(colorama.Style.BRIGHT),
reset=color(colorama.Style.RESET_ALL)))
else:
sys.stderr.write(u"\n{bold}Reboot Cancelled{reset}\n".format(
bold=color(colorama.Style.BRIGHT),
reset=color(colorama.Style.RESET_ALL)))

View File

@ -95,6 +95,7 @@ def select_command(corrected_commands):
selector.next()
logs.confirm_text(selector.value)
def confirm_command(confirmation_text):
"""Returns:
@ -107,13 +108,13 @@ def confirm_command(confirmation_text):
"""
logs.confirm_text(CorrectedCommand(confirmation_text,None,0))
logs.confirm_text(CorrectedCommand(confirmation_text, None, 0))
action = read_actions()
for action in read_actions():
if action == const.ACTION_SELECT:
sys.stderr.write('\n')
logs.confirmation(True)
return True
elif action == const.ACTION_ABORT:
logs.failed('\nAborted')
logs.confirmation(False)
return False