Skip to content
Myr

Use just the file name of the program name

Before adoption: this commit came in with the history the project adopted, so no landing records it.

If passed a full path to the executable (like done in the Makefile) that value is used in the generated completions. At least for fish this just doesn't work. This fixes #1172

authored by Bjoern Hiller · committed by Bjoern Hiller · parent 85e3ada · Browse files · 1 file+8 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−2 removed

  • other:+8 added−2 removed

1 file+8 added−2 removed

modified:src/main.rs+8 added-2 removed
91 unmodified lines
92#[cfg(feature = "completions")]93#[cold]94fn print_completions(shell: clap_complete::Shell) -> Result<ExitCode> {95 // The program name is the first argument.96 let program_name = env::args().next().unwrap_or_else(|| "fd".to_string());96 let first_arg = env::args().next();97 let program_name = first_arg98 .as_ref()99 .map(Path::new)100 .and_then(|path| path.file_name())101 .and_then(|file| file.to_str())102 .unwrap_or("fd");103 let mut cmd = Opts::command();104 cmd.build();99 clap_complete::generate(shell, &mut cmd, &program_name, &mut std::io::stdout());105 clap_complete::generate(shell, &mut cmd, program_name, &mut std::io::stdout());106 Ok(ExitCode::Success)107}108109fn set_working_dir(opts: &Opts) -> Result<()> {
336 unmodified lines