|
| 1 | +import sys |
| 2 | +from colorama import init, Fore, Style |
| 3 | +from main import launch_gui, launch_cli |
| 4 | + |
| 5 | +# Initialize colorama |
| 6 | +init(autoreset=True) |
| 7 | + |
| 8 | +def print_help(): |
| 9 | + help_text = f""" |
| 10 | +{Fore.YELLOW}{"Nodescope: An XML Editor and Visualizer".center(60)}{Style.RESET_ALL} |
| 11 | +
|
| 12 | +{Fore.CYAN}Usage:{Style.RESET_ALL} |
| 13 | + Select the desired mode by entering the corresponding number. |
| 14 | +
|
| 15 | +{Fore.CYAN}Modes:{Style.RESET_ALL} |
| 16 | + {Fore.GREEN}1.{Style.RESET_ALL} GUI - Launch the graphical user interface. |
| 17 | + {Fore.GREEN}2.{Style.RESET_ALL} CLI - Launch the command-line interface. |
| 18 | + {Fore.GREEN}3.{Style.RESET_ALL} Help - Show this help information. |
| 19 | + {Fore.GREEN}4.{Style.RESET_ALL} Exit - Exit the application. |
| 20 | +
|
| 21 | +{Fore.CYAN}Instructions:{Style.RESET_ALL} |
| 22 | + - Enter the number corresponding to your choice and press Enter. |
| 23 | + - For example, enter '1' to launch the GUI. |
| 24 | +""" |
| 25 | + print(help_text) |
| 26 | + |
| 27 | +def app(): |
| 28 | + print_help() |
| 29 | + |
| 30 | + while True: |
| 31 | + try: |
| 32 | + choice = input(f"{Fore.GREEN}Enter your choice (1/2/3/4): {Style.RESET_ALL}").strip() |
| 33 | + if choice == '1': |
| 34 | + print(f"{Fore.BLUE}Launching GUI...{Style.RESET_ALL}") |
| 35 | + launch_gui() |
| 36 | + break # Exit after launching GUI |
| 37 | + elif choice == '2': |
| 38 | + print(f"{Fore.BLUE}Launching CLI...{Style.RESET_ALL}") |
| 39 | + launch_cli() |
| 40 | + break # Exit after launching CLI |
| 41 | + elif choice == '3': |
| 42 | + print_help() |
| 43 | + elif choice == '4': |
| 44 | + print(f"{Fore.LIGHTRED_EX}Exiting application. Goodbye!{Style.RESET_ALL}") |
| 45 | + sys.exit(0) |
| 46 | + else: |
| 47 | + print(f"{Fore.RED}Invalid choice. Please enter 1, 2, 3, or 4.{Style.RESET_ALL}") |
| 48 | + except KeyboardInterrupt: |
| 49 | + print(f"\n{Fore.LIGHTRED_EX}Exiting application. Goodbye!{Style.RESET_ALL}") |
| 50 | + sys.exit(0) |
| 51 | + except Exception as e: |
| 52 | + print(f"{Fore.RED}An unexpected error occurred: {e}{Style.RESET_ALL}") |
| 53 | + |
| 54 | +if __name__ == "__main__": |
| 55 | + app() |
0 commit comments