@@ -62,7 +62,7 @@ struct Cli { |
| 62 | 62 | verbose: u8, |
| 63 | 63 | |
| 64 | 64 | #[command(subcommand)] |
| 65 | | - command: Commands, |
| 65 | + command: Option<Commands>, |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | #[derive(Subcommand)] |
@@ -144,19 +144,34 @@ fn main() -> anyhow::Result<()> { |
| 144 | 144 | .join("hyprkvm.toml") |
| 145 | 145 | }); |
| 146 | 146 | |
| 147 | | - // Handle GUI command outside of async runtime (Iced manages its own runtime) |
| 147 | + // Handle GUI: either explicit `gui` command OR no command (default) |
| 148 | 148 | #[cfg(feature = "gui")] |
| 149 | | - if matches!(cli.command, Commands::Gui) { |
| 149 | + if cli.command.is_none() || matches!(cli.command, Some(Commands::Gui)) { |
| 150 | 150 | info!("Starting HyprKVM GUI..."); |
| 151 | 151 | return gui::run_gui(&config_path); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | + // If GUI feature not enabled and no command given, show helpful message |
| 155 | + #[cfg(not(feature = "gui"))] |
| 156 | + if cli.command.is_none() { |
| 157 | + eprintln!("No command specified. Available commands:"); |
| 158 | + eprintln!(" hyprkvm daemon - Start the KVM daemon"); |
| 159 | + eprintln!(" hyprkvm status - Show daemon status"); |
| 160 | + eprintln!(" hyprkvm config - Configuration management"); |
| 161 | + eprintln!(); |
| 162 | + eprintln!("To enable the GUI, rebuild with: cargo build --features gui"); |
| 163 | + std::process::exit(1); |
| 164 | + } |
| 165 | + |
| 154 | 166 | // Run async commands in tokio runtime |
| 167 | + // At this point we know command is Some(...) because None cases are handled above |
| 168 | + let command = cli.command.expect("command should be Some at this point"); |
| 169 | + |
| 155 | 170 | tokio::runtime::Builder::new_multi_thread() |
| 156 | 171 | .enable_all() |
| 157 | 172 | .build()? |
| 158 | 173 | .block_on(async { |
| 159 | | - match cli.command { |
| 174 | + match command { |
| 160 | 175 | Commands::Daemon => { |
| 161 | 176 | info!("Starting HyprKVM daemon..."); |
| 162 | 177 | run_daemon(&config_path).await |