From 0310c5726f4d1e560ec39e0a6cd4298bbfe8dc07 Mon Sep 17 00:00:00 2001 From: Chris Webb Date: Fri, 23 Feb 2024 22:38:12 +0000 Subject: [PATCH] main: Show help text when run without arguments cloud-hypervisor, ch-remote, vhost-user-block and vhost-user-net all need at least one argument to do anything useful, so printing command help is helpful when they are run without arguments or a subcommand. Use clap::Command::arg_required_else_help(true) to do this. Signed-off-by: Chris Webb --- src/bin/ch-remote.rs | 1 + src/main.rs | 1 + vhost_user_block/src/main.rs | 1 + vhost_user_net/src/main.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/src/bin/ch-remote.rs b/src/bin/ch-remote.rs index f9236e375..d2a2baa81 100644 --- a/src/bin/ch-remote.rs +++ b/src/bin/ch-remote.rs @@ -898,6 +898,7 @@ fn main() { .author(env!("CARGO_PKG_AUTHORS")) .version(env!("BUILD_VERSION")) .about("Remotely control a cloud-hypervisor VMM.") + .arg_required_else_help(true) .subcommand_required(true) .args([ Arg::new("api-socket") diff --git a/src/main.rs b/src/main.rs index b9023ef5d..b9e2a1551 100644 --- a/src/main.rs +++ b/src/main.rs @@ -156,6 +156,7 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String // compile time .author(env!("CARGO_PKG_AUTHORS")) .about("Launch a cloud-hypervisor VMM.") + .arg_required_else_help(true) .group(ArgGroup::new("vm-config").multiple(true)) .group(ArgGroup::new("vmm-config").multiple(true)) .group(ArgGroup::new("logging").multiple(true)) diff --git a/vhost_user_block/src/main.rs b/vhost_user_block/src/main.rs index 2d7d68556..101d7131f 100644 --- a/vhost_user_block/src/main.rs +++ b/vhost_user_block/src/main.rs @@ -20,6 +20,7 @@ fn main() { .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS")) .about("Launch a vhost-user-blk backend.") + .arg_required_else_help(true) .arg( Arg::new("block-backend") .long("block-backend") diff --git a/vhost_user_net/src/main.rs b/vhost_user_net/src/main.rs index f9dc813e4..90f4e25e2 100644 --- a/vhost_user_net/src/main.rs +++ b/vhost_user_net/src/main.rs @@ -16,6 +16,7 @@ fn main() { .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS")) .about("Launch a vhost-user-net backend.") + .arg_required_else_help(true) .arg( Arg::new("net-backend") .long("net-backend")