From 38b9645bed66a6db6dfbcd9a80192132f6f725fb Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 9 Dec 2021 23:05:31 +0000 Subject: [PATCH] fix: Windows Multicall support The executable suffix is unconditionally stripped off the file path so that the file name matches subcommands names without having to add the EXE suffix on different platforms. --- examples/multicall_busybox.md | 8 ++++---- examples/multicall_hostname.md | 2 +- src/build/app/mod.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/multicall_busybox.md b/examples/multicall_busybox.md index 2bcd67e1e77..fc49a85ef5e 100644 --- a/examples/multicall_busybox.md +++ b/examples/multicall_busybox.md @@ -6,7 +6,7 @@ See the documentation for clap::AppSettings::Multicall for rationale. This example omits every command except true and false, which are the most trivial to implement, -```bash,ignore +```bash $ busybox true ? 0 $ busybox false @@ -16,20 +16,20 @@ $ busybox false But includes the `--install` option as an example of why it can be useful for the main program to take arguments that aren't applet subcommands. -```bash,ignore +```bash $ busybox --install ? failed ... ``` Though users must pass something: -```bash,ignore +```bash $ busybox ? failed busybox USAGE: - busybox[EXE] [OPTIONS] [APPLET] + busybox [OPTIONS] [APPLET] OPTIONS: -h, --help Print help information diff --git a/examples/multicall_hostname.md b/examples/multicall_hostname.md index e3707987505..cdef7ee70a7 100644 --- a/examples/multicall_hostname.md +++ b/examples/multicall_hostname.md @@ -6,7 +6,7 @@ See the documentation for clap::AppSettings::Multicall for rationale. This example omits the implementation of displaying address config -```bash,ignore +```bash $ hostname www ``` diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs index 7b53502c185..c58e60d8c50 100644 --- a/src/build/app/mod.rs +++ b/src/build/app/mod.rs @@ -607,7 +607,7 @@ impl<'help> App<'help> { if self.settings.is_set(AppSettings::Multicall) { if let Some((argv0, _)) = it.next() { let argv0 = Path::new(&argv0); - if let Some(command) = argv0.file_name().and_then(|f| f.to_str()) { + if let Some(command) = argv0.file_stem().and_then(|f| f.to_str()) { // Stop borrowing command so we can get another mut ref to it. let command = command.to_owned(); debug!(