@@ -7,9 +7,8 @@ use std::{
7
7
} ,
8
8
} ;
9
9
10
- use anyhow:: { Context , Result } ;
10
+ use anyhow:: { anyhow , Context , Result } ;
11
11
use clap:: { CommandFactory , Parser } ;
12
- use clap_complete:: { generate, generate_to} ;
13
12
use gitoxide_core as core;
14
13
use gitoxide_core:: { pack:: verify, repository:: PathsOrPatterns } ;
15
14
use gix:: bstr:: { io:: BufReadExt , BString } ;
@@ -1220,15 +1219,16 @@ pub fn main() -> Result<()> {
1220
1219
} ,
1221
1220
) ,
1222
1221
} ,
1223
- Subcommands :: GenerateCompletions { shell, out_dir } => {
1222
+ Subcommands :: Completions { shell, out_dir } => {
1224
1223
let mut app = Args :: command ( ) ;
1225
-
1224
+ let shell = shell
1225
+ . or_else ( clap_complete:: Shell :: from_env)
1226
+ . ok_or_else ( || anyhow ! ( "The shell could not be derived from the environment" ) ) ?;
1226
1227
if let Some ( out_dir) = out_dir {
1227
- generate_to ( shell, & mut app, env ! ( "CARGO_PKG_NAME" ) , & out_dir) ?;
1228
+ clap_complete :: generate_to ( shell, & mut app, env ! ( "CARGO_PKG_NAME" ) , & out_dir) ?;
1228
1229
} else {
1229
- generate ( shell, & mut app, env ! ( "CARGO_PKG_NAME" ) , & mut std:: io:: stdout ( ) ) ;
1230
+ clap_complete :: generate ( shell, & mut app, env ! ( "CARGO_PKG_NAME" ) , & mut std:: io:: stdout ( ) ) ;
1230
1231
}
1231
-
1232
1232
Ok ( ( ) )
1233
1233
}
1234
1234
} ?;
0 commit comments