@@ -49,17 +49,11 @@ fn get_completions_string<G: Generator>(gen: G, cmd: &mut ClapCommand) -> Result
49
49
}
50
50
51
51
pub fn completion_handler ( m : & ArgMatches , cmd : & mut ClapCommand ) -> Result < ( ) , Error > {
52
- let shell_result = m. get_one :: < Shell > ( "shell" ) ;
53
- if let Some ( shell) = shell_result {
54
- // Shell argument is provided, use it directly
55
- let completions = get_completions_string ( * shell, cmd) ?;
56
- println ! ( "{}" , completions) ;
57
- } else {
58
- // Shell argument is not provided, fall back to the default shell from the environment
59
- let shell = Shell :: from_env ( ) . ok_or ( Error :: MatchError ) ?;
60
- let completions = get_completions_string ( shell, cmd) ?;
61
- println ! ( "{}" , completions) ;
62
- println ! ( "# Since shell arg value is not provided trying to get the default shell from the environment." ) ;
63
- }
52
+ let shell = * m. get_one :: < Shell > ( "shell" ) . unwrap_or (
53
+ // if shell value is not provided try to get from the environment
54
+ & Shell :: from_env ( ) . ok_or ( Error :: MatchError ) ?,
55
+ ) ;
56
+ let completions = get_completions_string ( shell, cmd) ?;
57
+ println ! ( "{}" , completions) ;
64
58
Ok ( ( ) )
65
59
}
0 commit comments