1
1
use clap:: { Arg , Command , CommandFactory } ;
2
+ use fs_err as fs;
2
3
use itertools:: Itertools ;
3
4
use std:: cmp:: Ordering ;
4
5
use std:: collections:: HashMap ;
@@ -7,7 +8,6 @@ use std::fmt::Write;
7
8
use std:: path:: { Path , PathBuf } ;
8
9
use std:: process:: exit;
9
10
use std:: str:: FromStr ;
10
- use fs_err as fs;
11
11
12
12
const MD_EXTENSION : & str = ".md" ;
13
13
@@ -226,26 +226,24 @@ fn subcommands_table(subcommands: Vec<&Command>, parent: &str) -> String {
226
226
let about = if let Some ( about) = subcommand. get_about ( ) {
227
227
about
228
228
} else {
229
- eprintln ! ( "Warning: Subcommand `{}{}` has no description" , parent, subcommand. get_name( ) ) ;
229
+ eprintln ! (
230
+ "Warning: Subcommand `{}{}` has no description" ,
231
+ parent,
232
+ subcommand. get_name( )
233
+ ) ;
230
234
exit ( 1 ) ;
231
235
} ;
232
236
// Create a link to the subcommand's Markdown file
233
237
let command_name = subcommand. get_name ( ) ;
234
238
let link = format ! ( "{}/{}{}" , parent, command_name, MD_EXTENSION ) ;
235
239
let link_md = format ! ( "[`{}`]({})" , command_name, link) ;
236
- writeln ! (
237
- buffer,
238
- "| {} | {} |" ,
239
- link_md,
240
- about,
241
- )
242
- . unwrap ( ) ;
240
+ writeln ! ( buffer, "| {} | {} |" , link_md, about, ) . unwrap ( ) ;
243
241
}
244
242
buffer
245
243
}
246
244
247
245
// Function to write a list of options to the buffer
248
- fn arguments ( options : & [ & clap:: Arg ] , parents : & Vec < String > ) -> String {
246
+ fn arguments ( options : & [ & clap:: Arg ] , parents : & [ String ] ) -> String {
249
247
let mut buffer = String :: with_capacity ( 1024 ) ;
250
248
for opt in options {
251
249
if opt. is_hide_set ( ) ||
@@ -261,13 +259,21 @@ fn arguments(options: &[&clap::Arg], parents: &Vec<String>) -> String {
261
259
// No long name, but we have value names, assuming positional.
262
260
format ! ( "<{}>" , value_names[ 0 ] )
263
261
} else {
264
- eprintln ! ( "Error: Option: '{:?}' with parents {} has no long name" , opt, parents. join( " " ) ) ;
262
+ eprintln ! (
263
+ "Error: Option: '{:?}' with parents {} has no long name" ,
264
+ opt,
265
+ parents. join( " " )
266
+ ) ;
265
267
exit ( 1 ) ;
266
268
} ;
267
269
268
270
// Error on missing help
269
271
if opt. get_help ( ) . is_none ( ) && opt. get_long ( ) . unwrap ( ) != "help" {
270
- eprintln ! ( "Error: Option `{} {}` has no description" , parents. join( " " ) , long_name) ;
272
+ eprintln ! (
273
+ "Error: Option `{} {}` has no description" ,
274
+ parents. join( " " ) ,
275
+ long_name
276
+ ) ;
271
277
exit ( 1 ) ;
272
278
}
273
279
0 commit comments