diff --git a/src/app/config.rs b/src/app/config.rs index a0b5d05..38691fd 100644 --- a/src/app/config.rs +++ b/src/app/config.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; use std::path::PathBuf; -use clap::{Parser, ValueEnum}; +use clap::{Parser, Subcommand, ValueEnum}; use crate::core::engine::spec::{CloneSource, ExportSpec, StorageNamespace}; @@ -10,8 +10,13 @@ pub const CHUNK_SIZE: u64 = 4 * 1024 * 1024; #[derive(Debug, Clone, Parser)] #[command(author, version, about)] pub struct Cli { - #[command(flatten)] - pub serve: ServeConfigArgs, + #[command(subcommand)] + pub command: Command, +} + +#[derive(Debug, Clone, Subcommand)] +pub enum Command { + Serve(ServeConfigArgs), } #[derive(Debug, Clone, Parser)] diff --git a/src/main.rs b/src/main.rs index 4847321..82872f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use clap::Parser; use nbd_server::Cli; -use nbd_server::app::config::ServeConfig; +use nbd_server::app::config::{Command, ServeConfig}; use nbd_server::server::admin::serve_manager_admin; use nbd_server::server::manager::ExportManager; use nbd_server::storage::build_object_store; @@ -14,7 +14,9 @@ async fn main() -> nbd_server::Result<()> { .init(); let cli = Cli::parse(); - let serve = ServeConfig::from(cli.serve); + let serve = match cli.command { + Command::Serve(args) => ServeConfig::from(args), + }; let remote = build_object_store(&serve.storage).await?; let manager = ExportManager::new(serve.clone(), remote).await?; let admin_socket = serve.admin_sock.clone();