-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcvs.py
More file actions
80 lines (61 loc) · 1.84 KB
/
cvs.py
File metadata and controls
80 lines (61 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
"""
Entry point for CVS
"""
import sys
import argparse
def create_main_parser() -> argparse.ArgumentParser:
"""Create the main argument parser for interface selection"""
parser = argparse.ArgumentParser(
prog="cvs", description="A version control system with CLI and GUI interfaces"
)
parser.add_argument(
"--gui",
action="store_true",
help="Launch the graphical user interface (other args ignored)",
)
parser.add_argument(
"--cli", action="store_true", help="Use command line interface (default)"
)
return parser
def launch_gui():
"""Launch the GUI interface"""
try:
from gui.application import main as gui_main
print("Launching CVS GUI...")
gui_main()
except ImportError as e:
print(f"Error: Could not import GUI components: {e}")
print("Make sure all required dependencies are installed")
sys.exit(1)
except Exception as e:
print(f"Error launching GUI: {e}")
sys.exit(1)
def launch_cli(remaining):
"""Launch the CLI interface (pass remaining args to cli)"""
try:
original_argv = sys.argv
sys.argv = ["cvs"] + remaining
from cli import main as cli_main
cli_main()
except SystemExit as e:
if e.code != 0:
sys.exit(e.code)
except ImportError as e:
print(f"Error: Could not import CLI components: {e}")
sys.exit(1)
except Exception as e:
print(f"Error launching CLI: {e}")
sys.exit(1)
finally:
sys.argv = original_argv
def main():
"""Main entry point for CVS application"""
parser = create_main_parser()
args, remaining = parser.parse_known_args()
if args.gui:
launch_gui()
else:
launch_cli(remaining)
if __name__ == "__main__":
main()