-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.py
More file actions
125 lines (99 loc) · 2.83 KB
/
main.py
File metadata and controls
125 lines (99 loc) · 2.83 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python3
"""
macOS Cleaner - A beautiful console application for cleaning macOS
Main entry point
"""
import sys
import argparse
from pathlib import Path
from typing import Optional
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from ui.interface import CleanerInterface
from core.scanner import SystemScanner
from core.cleaner import SystemCleaner
from core.optimizer import SystemOptimizer
from utils.logger import setup_logger
from utils.config import load_config
console = Console()
logger = setup_logger(__name__)
def parse_arguments() -> argparse.Namespace:
"""Parse command line arguments."""
parser = argparse.ArgumentParser(
description="macOS Cleaner - Clean and optimize your Mac",
formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument(
"--scan-only",
action="store_true",
help="Only scan system without cleaning"
)
parser.add_argument(
"--auto",
action="store_true",
help="Automatically clean recommended items"
)
parser.add_argument(
"--config",
type=Path,
help="Path to configuration file"
)
parser.add_argument(
"--verbose",
"-v",
action="store_true",
help="Enable verbose output"
)
parser.add_argument(
"--version",
action="version",
version="%(prog)s 1.0.0"
)
return parser.parse_args()
def display_welcome():
"""Display welcome message."""
welcome_text = Text.from_markup(
"[bold cyan]macOS Cleaner[/bold cyan]\n"
"[dim]Clean and optimize your Mac with ease[/dim]"
)
panel = Panel(
welcome_text,
border_style="bright_blue",
padding=(1, 2)
)
console.print(panel)
console.print()
def main():
"""Main application entry point."""
try:
# Parse arguments
args = parse_arguments()
# Load configuration
config = load_config(args.config)
# Display welcome message
if not args.auto:
display_welcome()
# Initialize components
scanner = SystemScanner(config)
cleaner = SystemCleaner(config)
optimizer = SystemOptimizer(config)
# Create and run interface
interface = CleanerInterface(
scanner=scanner,
cleaner=cleaner,
optimizer=optimizer,
config=config,
auto_mode=args.auto,
scan_only=args.scan_only
)
interface.run()
except KeyboardInterrupt:
console.print("\n[yellow]Operation cancelled by user[/yellow]")
sys.exit(0)
except Exception as e:
logger.error(f"Unexpected error: {e}")
console.print(f"\n[red]Error: {e}[/red]")
sys.exit(1)
if __name__ == "__main__":
main()