gardesk/gartop / 32dcb72

Browse files

Add --pane flag, allow dead_code for future features

Authored by espadonne
SHA
32dcb72dd64209fc0715e46bc37f49c740945879
Parents
22b5e03
Tree
7c140ef

1 changed file

StatusFile+-
M gartop/src/main.rs 24 7
gartop/src/main.rsmodified
@@ -3,6 +3,8 @@
33
 //! A daemon-based system monitor with real-time CPU, memory, and process
44
 //! monitoring. Uses gartk for GUI rendering.
55
 
6
+#![allow(dead_code)] // Many fields/methods are for future features (Phase 5, 6)
7
+
68
 use anyhow::Result;
79
 use clap::{Parser, Subcommand};
810
 use tracing_subscriber::EnvFilter;
@@ -29,18 +31,26 @@ struct Cli {
2931
     /// Configuration file path
3032
     #[arg(short, long)]
3133
     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>,
3238
 }
3339
 
3440
 #[derive(Subcommand)]
3541
 enum Commands {
36
-    /// Start the daemon (default)
42
+    /// Start the daemon
3743
     Daemon {
3844
         /// Run in foreground
3945
         #[arg(short, long)]
4046
         foreground: bool,
4147
     },
4248
     /// 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
+    },
4454
 }
4555
 
4656
 #[tokio::main]
@@ -58,15 +68,22 @@ async fn main() -> Result<()> {
5868
             tracing::info!("Starting gartop daemon");
5969
             daemon::run(cli.config, foreground || cli.foreground).await
6070
         }
61
-        Some(Commands::Gui) => {
71
+        Some(Commands::Gui { pane }) => {
6272
             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
+            }
6477
             gui::run(cfg.gui).await
6578
         }
6679
         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
7087
         }
7188
     }
7289
 }