1- from src .processors .xml_processor import XMLProcessor
1+ import argparse
2+ import subprocess
3+ import sys
4+ from colorama import init , Fore , Style
5+
6+ # Initialize colorama
7+ init (autoreset = True )
8+
9+ def launch_gui ():
10+ from src .gui .gui_handler import App
11+ app = App ()
12+ app .mainloop ()
13+
14+ def print_ascii_banner ():
15+ banner = """
16+ {}
17+ ::
18+ %%
19+ %%
20+ #*:*##%#+. -*###%#= -*%###+:%% .=#####+: .+#%%%#+: =*%%%%#+. .=*%%%%#=. *#+=#%%%#=. :+#%%%#+:
21+ %%#. -%# #%- :#%. +%+ -%%% :%# *%- .%%%:.-**= .%%%#)%%%. -%%% %%%: #%%%*==*%%%: =%%# *%%=
22+ %% #% *%- .%# :%+ .%% %%=::::::%% #%%+-:. *%%: .%%%: .%%# #%%. :%%% :%%%=====#%%
23+ %# *% %%. #% =%- %% .%%========= -+*#%%%+ #%% .%%# *%% #%* #%%.-%%.
24+ %# *% =%+ -%+ .%# =%% *%- -. .-+: +%%- =%%+. =+-. #%%+. .=%%* #%%= .+%%* %%%: ==.
25+ %# *% :##=--=#%= :#%+--=#*%% =%*=--+%#: .*%%%##%%* =#%%%%%%%+ +%%%%%%%%= #%%#%%%%%%= .*%%%#%%%#:
26+ -- :- :-===: .===-. -- :===-. .-===-. :-===- :====: #%# :===- -===-.
27+ #%#
28+ #%#
29+
30+ Nodescope: an XML Editor and Visualizer
31+ {}""" .format (Fore .CYAN , Style .RESET_ALL )
32+ print (banner )
33+
34+ def launch_cli ():
35+ print_ascii_banner ()
36+ while True :
37+ try :
38+ # Prompt the user for input with styled text
39+ command = input (f"{ Fore .GREEN } >> { Style .RESET_ALL } " )
40+ if command .lower () in ["exit" , "quit" ]:
41+ print ("Exiting CLI mode." )
42+ break
43+ # Pass the command to the CLI handler
44+ subprocess .run (["python" , "src/cli/cli_handler.py" ] + command .split (), check = True )
45+ except subprocess .CalledProcessError as e :
46+ print (f"Error: { e } " )
47+ except KeyboardInterrupt :
48+ print ("\n Exiting CLI mode." )
49+ break
250
351def main ():
4- processor = XMLProcessor ("sample_files/sample.xml" )
5- processor .prettify ().minify ().compress ().save ("sample_files/output.xml" )
6- print ("Operations completed successfully!" )
52+ parser = argparse .ArgumentParser (description = "nodescope: an XML Editor and Visualizer" )
53+ parser .add_argument ("--gui" , action = "store_true" , help = "Launch GUI interface" )
54+ parser .add_argument ("--cli" , action = "store_true" , help = "Launch CLI interface" )
55+
56+ args = parser .parse_args ()
57+
58+ if args .gui :
59+ launch_gui ()
60+ elif args .cli :
61+ launch_cli ()
62+ else :
63+ parser .print_help ()
764
865if __name__ == "__main__" :
966 main ()
0 commit comments