From 0f5847bfda045600b63a19304503cc5d4f4bc80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Istv=C3=A1n=20B=C3=ADr=C3=B3?= Date: Thu, 5 Dec 2024 17:26:41 +0100 Subject: [PATCH] fix usage string and some errors --- wasm-rpc-stubgen/src/commands/app.rs | 2 +- wasm-rpc-stubgen/src/lib.rs | 2 +- wasm-rpc-stubgen/src/main.rs | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/wasm-rpc-stubgen/src/commands/app.rs b/wasm-rpc-stubgen/src/commands/app.rs index d295b14..68bc6af 100644 --- a/wasm-rpc-stubgen/src/commands/app.rs +++ b/wasm-rpc-stubgen/src/commands/app.rs @@ -741,7 +741,7 @@ fn collect_sources(mode: &ApplicationSourceMode) -> ValidatedResult }) } } - None => ValidatedResult::from_error("No config file found!".to_string()), + None => ValidatedResult::from_error("No application manifest found!".to_string()), }, ApplicationSourceMode::Explicit(sources) => { let non_unique_source_warns: Vec<_> = sources diff --git a/wasm-rpc-stubgen/src/lib.rs b/wasm-rpc-stubgen/src/lib.rs index 5bd0318..770ff46 100644 --- a/wasm-rpc-stubgen/src/lib.rs +++ b/wasm-rpc-stubgen/src/lib.rs @@ -307,7 +307,7 @@ pub fn initialize_workspace( } pub async fn run_app_command( - clap_command: &mut clap::Command, + mut clap_command: clap::Command, command: App, ) -> anyhow::Result<()> { let (mut config, subcommand) = app_command_to_config_and_subcommand::(command); diff --git a/wasm-rpc-stubgen/src/main.rs b/wasm-rpc-stubgen/src/main.rs index b213c44..63b865d 100644 --- a/wasm-rpc-stubgen/src/main.rs +++ b/wasm-rpc-stubgen/src/main.rs @@ -46,7 +46,20 @@ async fn main() -> ExitCode { #[cfg(feature = "app-command")] Command::App { command } => { run_app_command::( - clap_command.find_subcommand_mut("app").unwrap(), + { + // TODO: it would be nice to use the same logic which is used by default for handling help, + // and that way include the current context (bin name and parent commands), + // but that seems to be using errors, error formating and exit directly; + // and quite different code path compared to calling print_help + clap_command + .find_subcommand_mut("app") + .unwrap() + .clone() + .override_usage(format!( + "{} [OPTIONS] [COMMAND]", + "wasm-rpc-stubgen app".bold() + )) + }, command, ) .await