RustWhy is a unified CLI that runs multiple diagnostic modules. Each module implements the DiagnosticModule trait, collects system data, and returns a DiagnosticReport.
- CLI (
src/cli/): Argument parsing (Clap), subcommands, shell completions. - Core (
src/core/):DiagnosticModuletrait,DiagnosticReport,Finding,Recommendation,Severity, and the runner that executes modules. - Modules (
src/modules/): One file per diagnostic (boot, cpu, mem, disk, io, net, fan, temp, gpu, batt, sleep, usb, mount). Each exposes amodule()that returnsArc<dyn DiagnosticModule>. - Output (
src/output/): Terminal (colored), JSON, and table formatting. - Utils (
src/utils/): System commands, process helpers, file/parse/format utilities, permission checks.
main.rsparses CLI and maps subcommand to module name +ModuleConfig.run_module(module, config)is called (async); the module reads/proc,/sys, or external tools.- Module returns
DiagnosticReport(findings, metrics, recommendations). - Report is printed via
write_report_terminalorwrite_report_json.
- Add a new module: implement
DiagnosticModuleinsrc/modules/<name>.rs, register inmod.rs, add subcommand inargs.rsand wiring inmain.rs. - Add a new output format: add a writer in
src/output/and call it frommain.rsbased on CLI.