From 5a9f23f6b6910bc2de23b369c18da81354229e81 Mon Sep 17 00:00:00 2001 From: Subnet_Masked Date: Sun, 4 Feb 2024 18:44:43 -0500 Subject: [PATCH] Options to cancel --- mc_control.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mc_control.py b/mc_control.py index db7a922..3aa8e1d 100644 --- a/mc_control.py +++ b/mc_control.py @@ -59,18 +59,29 @@ def pop_server(): global servers # Global so we can write print(colored('\n=== Remove Server ===\nPick a server to delete','red')) print(colored(list_servers(2),'light_blue')) # Lists server ID and Name only. - delete = int(input(colored('?: ','yellow'))) - servers.pop(delete) + delete = input(colored('(enter to cancel) ?: ','yellow')) + if(delete==""): + print(colored('Cancelled\n','red')) + return + servers.pop(int(delete)) + print(colored('Deleted\n','light_blue')) write_servers() # Let's send some commands to the servers! def send_commands(): proceed=True # Used in while loops to determine if we still want to send more commands. print(colored('\n=== Send commands ===','green')) - choice = int(input(colored('Single Server (1) or All (2)?: ','yellow'))) - if(choice==1): # We only want to interact with one server. + choice = input(colored('(Enter to cancel) Single (1) All (2)?: ','yellow')) + if(choice==""): + print(colored('Cancelled\n','red')) + return + if(choice=="1"): # We only want to interact with one server. print(colored(list_servers(2),'light_blue')) # Show us which servers we can pick from. - server = int(input(colored('Server?: ','yellow'))) + server = input(colored('(Enter to cancel) Server?: ','yellow')) + if(server==""): + print(colored('Cancelled\n','red')) + return + server=int(server) while(proceed): command = input(colored('Input command (None to exit): ','yellow')) if(command!=""): @@ -81,7 +92,7 @@ def send_commands(): else: proceed = False print(colored('No command was entered. Exiting.\n','red')) - elif(choice==2): + elif(choice=="2"): while(proceed): command = input(colored('Input command (None to exit): ','yellow')) for x in servers: # Run for each server.