-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkryptinfo.cpp
More file actions
54 lines (45 loc) · 1.43 KB
/
kryptinfo.cpp
File metadata and controls
54 lines (45 loc) · 1.43 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
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstdlib>
void executeCommand(const std::string& command) {
int result = std::system(command.c_str());
if (result != 0) {
std::cerr << "Failed to execute the command: " << command << std::endl;
}
}
void displayMenu() {
std::cout << "\n\n\n\t==== System info ====" << std::endl;
std::cout << "\t1: dmesg as superuser" << std::endl;
std::cout << "\t2: lsb_release -a" << std::endl;
std::cout << "\t3: lspci" << std::endl;
std::cout << "\t4: uname -a" << std::endl;
std::cout << "\t5: fastfetch" << std::endl;
std::cout << "\t0: exit" << std::endl;
std::cout << "\t=====================" << std::endl;
}
int main() {
std::unordered_map<std::string, std::string> commands = {
{"1", "sudo dmesg"},
{"2", "lsb_release -a"},
{"3", "lspci"},
{"4", "uname -a"},
{"5", "fastfetch"}
};
std::string choice;
do {
displayMenu();
std::cout << "> ";
std::cin >> choice;
if (choice == "0") {
std::cout << "\nexit the program." << std::endl;
break;
}
if (commands.find(choice) != commands.end()) {
executeCommand(commands[choice]);
} else {
std::cout << "\nIt is an invalid option. Please specify 1~5 or 0.\n";
}
} while (true);
return 0;
}