mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 09:39:01 +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:
parent
488b8ca6ab
commit
6f99e2ea7f
@ -42,7 +42,6 @@ def fix_command(known_args):
|
|||||||
corrected_commands = get_corrected_commands(command)
|
corrected_commands = get_corrected_commands(command)
|
||||||
selected_command = select_command(corrected_commands)
|
selected_command = select_command(corrected_commands)
|
||||||
|
|
||||||
|
|
||||||
confirmation = True
|
confirmation = True
|
||||||
if selected_command.script == "reboot":
|
if selected_command.script == "reboot":
|
||||||
confirmation = confirm_command("Reboot System?")
|
confirmation = confirm_command("Reboot System?")
|
||||||
|
@ -139,3 +139,14 @@ def version(thefuck_version, python_version, shell_info):
|
|||||||
u'The Fuck {} using Python {} and {}\n'.format(thefuck_version,
|
u'The Fuck {} using Python {} and {}\n'.format(thefuck_version,
|
||||||
python_version,
|
python_version,
|
||||||
shell_info))
|
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)))
|
||||||
|
@ -95,6 +95,7 @@ def select_command(corrected_commands):
|
|||||||
selector.next()
|
selector.next()
|
||||||
logs.confirm_text(selector.value)
|
logs.confirm_text(selector.value)
|
||||||
|
|
||||||
|
|
||||||
def confirm_command(confirmation_text):
|
def confirm_command(confirmation_text):
|
||||||
"""Returns:
|
"""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()
|
action = read_actions()
|
||||||
for action in read_actions():
|
for action in read_actions():
|
||||||
if action == const.ACTION_SELECT:
|
if action == const.ACTION_SELECT:
|
||||||
sys.stderr.write('\n')
|
logs.confirmation(True)
|
||||||
return True
|
return True
|
||||||
elif action == const.ACTION_ABORT:
|
elif action == const.ACTION_ABORT:
|
||||||
logs.failed('\nAborted')
|
logs.confirmation(False)
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user