|
| 1 | +#include <cstdlib> |
| 2 | +#include <iostream> |
| 3 | +#include <string> |
| 4 | +#include <vector> |
| 5 | + |
| 6 | +#include <ox/core/core.hpp> |
| 7 | + |
| 8 | +#include "menu_app.h" |
| 9 | +#include "menu_builder.h" |
| 10 | + |
| 11 | +int main() |
| 12 | +{ |
| 13 | + try { |
| 14 | + auto menu = menu_() |
| 15 | + .menu("Networking", "") |
| 16 | + .item("Network Manager", "nmtui") |
| 17 | + .item("IP Address", "ip a") |
| 18 | + .item("Routes", "ip r") |
| 19 | + .item("DNS (resolvectl)", "resolvectl status") |
| 20 | + .item("Sockets", "ss -tulpen") |
| 21 | + .item("Ping", "ping -c 4 1.1.1.1") |
| 22 | + .item("Firewall (nft)", "nft list ruleset") |
| 23 | + .end() |
| 24 | + .menu("System", "") |
| 25 | + .item("System Info", "fastfetch") |
| 26 | + .item("Uptime/Load", "uptime") |
| 27 | + .item("Kernel/OS", "uname -a") |
| 28 | + .item("Kernel Logs", "dmesg") |
| 29 | + .item("Top", "timeout 5 htop") |
| 30 | + .item("Memory", "free -h") |
| 31 | + .item("CPU Info", "lscpu") |
| 32 | + .item("USB Info", "lsusb") |
| 33 | + .item("Block Devices", "lsblk") |
| 34 | + .end() |
| 35 | + .menu("Files", "") |
| 36 | + .item("List Files", "ls -lah") |
| 37 | + .item("Disk Usage", "du -sh *") |
| 38 | + .item("Filesystem Usage", "df -h") |
| 39 | + .end() |
| 40 | + .menu("Services", "") |
| 41 | + .item("Service Status", "systemctl --failed") |
| 42 | + .item("All Services", "systemctl list-units --type=service") |
| 43 | + .item("Timers", "systemctl list-timers") |
| 44 | + .item("Startup Time", "systemd-analyze") |
| 45 | + .end() |
| 46 | + .menu("Storage", "") |
| 47 | + .item("fstab", "cat /etc/fstab") |
| 48 | + .item("blkid", "blkid") |
| 49 | + .end() |
| 50 | + .menu("Security", "") |
| 51 | + .item("Who Is Logged In", "who") |
| 52 | + .item("Sudo Version", "sudo -V | head -n 1") |
| 53 | + .item("Open Ports", "ss -lntup") |
| 54 | + .end() |
| 55 | + .build(); |
| 56 | + |
| 57 | + std::string output; |
| 58 | + int code = 0; |
| 59 | + { |
| 60 | + auto term = ox::Terminal{}; |
| 61 | + auto app = MenuApp{std::move(menu), output}; |
| 62 | + code = ox::process_events(term, app); |
| 63 | + } |
| 64 | + if (!output.empty()) { |
| 65 | + std::cout << output << '\n'; |
| 66 | + return std::system(output.c_str()); |
| 67 | + } |
| 68 | + return code; |
| 69 | + } |
| 70 | + catch (std::exception const& e) { |
| 71 | + std::cerr << "Error: " << e.what() << '\n'; |
| 72 | + return 1; |
| 73 | + } |
| 74 | + catch (...) { |
| 75 | + std::cerr << "Unknown error\n"; |
| 76 | + return 1; |
| 77 | + } |
| 78 | +} |
0 commit comments