@@ -3,6 +3,8 @@ |
| 3 | 3 | //! A daemon-based system monitor with real-time CPU, memory, and process |
| 4 | 4 | //! monitoring. Uses gartk for GUI rendering. |
| 5 | 5 | |
| 6 | +#![allow(dead_code)] // Many fields/methods are for future features (Phase 5, 6) |
| 7 | + |
| 6 | 8 | use anyhow::Result; |
| 7 | 9 | use clap::{Parser, Subcommand}; |
| 8 | 10 | use tracing_subscriber::EnvFilter; |
@@ -29,18 +31,26 @@ struct Cli { |
| 29 | 31 | /// Configuration file path |
| 30 | 32 | #[arg(short, long)] |
| 31 | 33 | config: Option<String>, |
| 34 | + |
| 35 | + /// Open to specific pane (for garbar integration) |
| 36 | + #[arg(short, long, value_parser = ["cpu", "memory", "network", "disk"])] |
| 37 | + pane: Option<String>, |
| 32 | 38 | } |
| 33 | 39 | |
| 34 | 40 | #[derive(Subcommand)] |
| 35 | 41 | enum Commands { |
| 36 | | - /// Start the daemon (default) |
| 42 | + /// Start the daemon |
| 37 | 43 | Daemon { |
| 38 | 44 | /// Run in foreground |
| 39 | 45 | #[arg(short, long)] |
| 40 | 46 | foreground: bool, |
| 41 | 47 | }, |
| 42 | 48 | /// Open the GUI window (connects to daemon) |
| 43 | | - Gui, |
| 49 | + Gui { |
| 50 | + /// Open to specific pane |
| 51 | + #[arg(short, long, value_parser = ["cpu", "memory", "network", "disk"])] |
| 52 | + pane: Option<String>, |
| 53 | + }, |
| 44 | 54 | } |
| 45 | 55 | |
| 46 | 56 | #[tokio::main] |
@@ -58,15 +68,22 @@ async fn main() -> Result<()> { |
| 58 | 68 | tracing::info!("Starting gartop daemon"); |
| 59 | 69 | daemon::run(cli.config, foreground || cli.foreground).await |
| 60 | 70 | } |
| 61 | | - Some(Commands::Gui) => { |
| 71 | + Some(Commands::Gui { pane }) => { |
| 62 | 72 | tracing::info!("Starting gartop GUI"); |
| 63 | | - let cfg = config::Config::load(cli.config.as_deref())?; |
| 73 | + let mut cfg = config::Config::load(cli.config.as_deref())?; |
| 74 | + if let Some(p) = pane { |
| 75 | + cfg.gui.default_pane = Some(p); |
| 76 | + } |
| 64 | 77 | gui::run(cfg.gui).await |
| 65 | 78 | } |
| 66 | 79 | None => { |
| 67 | | - // Default: start daemon |
| 68 | | - tracing::info!("Starting gartop daemon"); |
| 69 | | - daemon::run(cli.config, cli.foreground).await |
| 80 | + // Default: start GUI (use --pane if provided) |
| 81 | + tracing::info!("Starting gartop GUI"); |
| 82 | + let mut cfg = config::Config::load(cli.config.as_deref())?; |
| 83 | + if let Some(p) = cli.pane { |
| 84 | + cfg.gui.default_pane = Some(p); |
| 85 | + } |
| 86 | + gui::run(cfg.gui).await |
| 70 | 87 | } |
| 71 | 88 | } |
| 72 | 89 | } |