Skip to content

Commit 408883a

Browse files
committed
Main app deployment
1 parent eb45e14 commit 408883a

2 files changed

Lines changed: 88 additions & 6 deletions

File tree

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- [**Prerequisites**](#prerequisites)
1515
- [**Installation**](#installation)
1616
- [**Usage**](#usage)
17+
- [**Directly from Main**](#directly-from-main)
1718
- [**Command Line Interface (CLI)**](#command-line-interface-cli)
1819
- [**Graphical User Interface (GUI)**](#graphical-user-interface-gui)
1920
- [**Commands Overview**](#commands-overview)
@@ -64,10 +65,34 @@ The XML Editor and Visualizer is a project developed for the Data Structures and
6465

6566
## **Usage**
6667

68+
### **Directly from Main**
69+
The main script allows you to choose either interface, you can run it directly from root:
70+
```bash
71+
python main.py
72+
```
73+
> Displays a help message with available options.
74+
> Choose either `--cli` or `--gui` to launch the respective interface.
75+
76+
```bash
77+
python main.py --gui
78+
```
79+
> Launches the GUI for visual interaction with XML files.
80+
81+
```bash
82+
python main.py --cli
83+
```
84+
> Launches the CLI for quick operations on XML files, in a shell-like environment.
85+
> Simply type the [command](#commands-overview) followed by the required arguments.
86+
> For example:
87+
> ```bash
88+
> >> verify -i input.xml -f -o fixed.xml
89+
> ```
90+
> To exit the CLI, type `exit` or `quit`.
91+
6792
### **Command Line Interface (CLI)**
68-
Perform quick and efficient operations on XML files via the CLI:
93+
Perform quick and efficient operations on XML files via the CLI using the `.bat` script provided, `xml_editor`:
6994
```bash
70-
xml_editor [command] -i [input_file] -o [output_file]
95+
./xml_editor [command] -i [input_file] -o [output_file]
7196
```
7297
> [!TIP]
7398
> Replace `[command]` with one of the available commands listed [below](#commands-overview).

main.py

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,66 @@
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("\nExiting CLI mode.")
49+
break
250

351
def 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

865
if __name__ == "__main__":
966
main()

0 commit comments

Comments
 (0)