-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
121 lines (107 loc) · 4.35 KB
/
Copy pathmain.cpp
File metadata and controls
121 lines (107 loc) · 4.35 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
// ============================================================================
// FILE: main.cpp
// SpaceMate - Smart Disk Manager
// Entry Point and CLI Interface
// ============================================================================
#include "include/disk_monitor.h"
#include "include/file_analyzer.h"
#include "include/cleanup_manager.h"
#include "include/backup_manager.h"
#include "include/utils.h"
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;
// ANSI Color Codes
#define RESET "\033[0m"
#define RED "\033[31m"
#define GREEN "\033[32m"
#define YELLOW "\033[33m"
#define BLUE "\033[34m"
#define CYAN "\033[36m"
#define BOLD "\033[1m"
void printBanner() {
cout << CYAN << BOLD;
cout << "╔════════════════════════════════════════╗\n";
cout << "║ SpaceMate - Smart Disk Manager ║\n";
cout << "║ Team Raptors #057 ║\n";
cout << "╚════════════════════════════════════════╝\n";
cout << RESET << "\n";
}
void printHelp() {
cout << BOLD << "Usage:" << RESET << " ./spacemate <command> <path> [options]\n\n";
cout << BOLD << "Commands:\n" << RESET;
cout << " scan <path> - Scan disk usage and show statistics\n";
cout << " analyze <path> - Analyze files (duplicates, temp files, old files)\n";
cout << " clean <path> - Clean up unnecessary files\n";
cout << " restore - Restore backed up files\n";
cout << " help - Show this help message\n\n";
cout << BOLD << "Options:\n" << RESET;
cout << " --dry-run - Preview cleanup without making changes\n";
cout << " --verbose - Show detailed output\n";
cout << " --force - Skip confirmations (use with caution)\n\n";
cout << BOLD << "Examples:\n" << RESET;
cout << " ./spacemate scan ~/Downloads\n";
cout << " ./spacemate analyze ~/Documents --verbose\n";
cout << " ./spacemate clean ~/temp --dry-run\n";
cout << " ./spacemate restore\n\n";
}
int main(int argc, char* argv[]) {
printBanner();
if (argc < 2) {
printHelp();
return 1;
}
string command = argv[1];
string path = argc > 2 ? argv[2] : ".";
bool dryRun = false;
bool verbose = false;
bool force = false;
// Parse options
for (int i = 3; i < argc; i++) {
string arg = argv[i];
if (arg == "--dry-run") dryRun = true;
else if (arg == "--verbose") verbose = true;
else if (arg == "--force") force = true;
}
try {
if (command == "help" || command == "--help" || command == "-h") {
printHelp();
}
else if (command == "scan") {
cout << BLUE << "📊 Scanning: " << RESET << path << "\n\n";
DiskMonitor monitor;
monitor.scanPath(path, verbose);
}
else if (command == "analyze") {
cout << BLUE << "🔍 Analyzing: " << RESET << path << "\n\n";
FileAnalyzer analyzer;
analyzer.analyzePath(path, verbose);
}
else if (command == "clean") {
if (dryRun) {
cout << YELLOW << "🔍 DRY RUN MODE - No files will be deleted\n" << RESET;
}
cout << BLUE << "🧹 Cleaning: " << RESET << path << "\n\n";
CleanupManager cleaner;
cleaner.cleanPath(path, dryRun, force, verbose);
}
else if (command == "restore") {
cout << BLUE << "📦 Restore Manager\n" << RESET << "\n";
BackupManager backup;
backup.showBackups();
backup.restoreFiles();
}
else {
cout << RED << "Error: Unknown command '" << command << "'\n" << RESET;
cout << "Run './spacemate help' for usage information.\n";
return 1;
}
cout << "\n" << GREEN << "✓ Operation completed successfully!\n" << RESET;
} catch (const exception& e) {
cout << RED << "Error: " << e.what() << RESET << "\n";
return 1;
}
return 0;
}