ch-remote: Fix crash when run with no subcommand

ch-remote crashes when run with --api-socket but no subcommand:

  $ target/release/ch-remote --api-socket /tmp/api
  thread 'main' panicked at src/bin/ch-remote.rs:509:14:
  internal error: entered unreachable code

Use clap::Command::subcommand_required(true) to yield a more friendly
error in this case.

Signed-off-by: Chris Webb <chris@arachsys.com>
This commit is contained in:
Chris Webb 2024-02-23 16:55:12 +00:00 committed by Rob Bradford
parent 07560c596d
commit 5627c26405

View File

@ -898,6 +898,7 @@ fn main() {
.author(env!("CARGO_PKG_AUTHORS")) .author(env!("CARGO_PKG_AUTHORS"))
.version(env!("BUILD_VERSION")) .version(env!("BUILD_VERSION"))
.about("Remotely control a cloud-hypervisor VMM.") .about("Remotely control a cloud-hypervisor VMM.")
.subcommand_required(true)
.args([ .args([
Arg::new("api-socket") Arg::new("api-socket")
.long("api-socket") .long("api-socket")