File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -93,10 +93,16 @@ fn run() -> Result<ExitCode> {
93
93
#[ cold]
94
94
fn print_completions ( shell : clap_complete:: Shell ) -> Result < ExitCode > {
95
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_arg
98
+ . as_ref ( )
99
+ . map ( Path :: new)
100
+ . and_then ( |path| path. file_name ( ) )
101
+ . and_then ( |file| file. to_str ( ) )
102
+ . unwrap_or ( "fd" ) ;
97
103
let mut cmd = Opts :: command ( ) ;
98
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 ( ) ) ;
100
106
Ok ( ExitCode :: Success )
101
107
}
102
108
You can’t perform that action at this time.
0 commit comments