Ver Fonte

main menu choice

serinko há 4 anos atrás
pai
commit
ee7d7bf6ac
2 ficheiros alterados com 63 adições e 5 exclusões
  1. 19 2
      texts_cli.py
  2. 44 3
      whallets_cli.py

+ 19 - 2
texts_cli.py

@@ -12,8 +12,8 @@ def welcome_message():
 
 def _main_menu():
     """Displays the CLI main menu"""
-    line_0 = ("**","Enter a number from the menu:")
-    line = ("---","------------------------------",)
+    line_0 = ("**","Chose an operation from the menu:")
+    line = ("---","---------------------------------",)
     line_1 = ("1 -","Add a wallet to the your list")
     line_2 = ("2 -","Remove a wallet from your list")
     line_3 = ("3 -","Display your wallet list")
@@ -33,6 +33,23 @@ def _main_menu():
     ]
     return table
 
+def _menu_choice():
+    """Sentence asking user for the next step"""
+    msg = "\nEnter number and press Enter:"
+    return msg
+
+def _missing_operation():
+    """Inform about non-existing users choice"""
+    msg = "Sorry, but you had either choosen an unexisting option, "\
+    "or this operation has not been developped yet."
+    return msg
+
+def _ask_new_choice():
+    """Message offering a new choice or quit"""
+    msg = "Do you have another choice?\n1 - YES\n2 - NO (quit)"
+    return msg
+
+
 
 def _choose_chain():
     msg = \

+ 44 - 3
whallets_cli.py

@@ -12,12 +12,49 @@ from tabulate import tabulate
 
 import texts_cli as tc
 
+print(tc.welcome_message())
+
 def cli_main():
     """Main program for the cli"""
-    print(tc.welcome_message())
 
-def main_menu():
-    """main cli options"""
+    while True:
+        print(tabulate(tc._main_menu()))
+        main_menu_choice()
+
+def main_menu_choice():
+    """main cli operations choice"""
+    choice = input(tc._main_menu())
+    if choice == 1:
+        add_wallet()
+    elif choice == 2:
+        remove_wallet()
+    elif choice == 3:
+        display_all_wallets()
+    elif choice == 4:
+        print(tc._missing_operation())
+        _new_choice()
+    elif choice == 5:
+        print(tc._missing_operation())
+        _new_choice()
+    elif choice.lower() == "q":
+        quit()
+    else:
+        _new_choice()
+
+def _new_choice():
+    """Offer user a new choice"""
+
+    x = 1
+    if x < 3:
+        choice = input(tc._ask_new_choice())
+        if choice == 1:
+            cli_main()
+        elif choice == 2:
+            quit()
+        else:
+            x += 1
+    else:
+        quit()
 
 def add_wallet():
     """A function to add wallet to the wallets_dict.json"""
@@ -25,6 +62,10 @@ def add_wallet():
     msg = tc._check_wallet_result(chain, name, addr, twtr, ens)
     print(msg)
 
+def remove_wallet():
+    """Removes wallet from the wallet dictionary"""
+    # This function needs to be developped
+
 def _get_inputs():
     """Get infor to add a new wallet"""
     chain = int(input(tc._choose_chain()))