@@ -20,10 +20,9 @@ impl Generator for Bash {
20
20
21
21
let fn_name = bin_name. replace ( '-' , "__" ) ;
22
22
23
- w ! (
23
+ write ! (
24
24
buf,
25
- format!(
26
- "_{name}() {{
25
+ "_{name}() {{
27
26
local i cur prev opts cmd
28
27
COMPREPLY=()
29
28
cur=\" ${{COMP_WORDS[COMP_CWORD]}}\"
66
65
complete -F _{name} -o bashdefault -o default {name}
67
66
fi
68
67
" ,
69
- name = bin_name,
70
- cmd = fn_name,
71
- name_opts = all_options_for_path( cmd, bin_name) ,
72
- name_opts_details = option_details_for_path( cmd, bin_name) ,
73
- subcmds = all_subcommands( cmd, & fn_name) ,
74
- subcmd_details = subcommand_details( cmd)
75
- )
76
- . as_bytes( )
77
- ) ;
68
+ name = bin_name,
69
+ cmd = fn_name,
70
+ name_opts = all_options_for_path( cmd, bin_name) ,
71
+ name_opts_details = option_details_for_path( cmd, bin_name) ,
72
+ subcmds = all_subcommands( cmd, & fn_name) ,
73
+ subcmd_details = subcommand_details( cmd)
74
+ ) . expect ( "failed to write completion file" ) ;
78
75
}
79
76
}
80
77
@@ -274,22 +271,23 @@ fn all_options_for_path(cmd: &Command, path: &str) -> String {
274
271
275
272
let mut opts = String :: new ( ) ;
276
273
for short in utils:: shorts_and_visible_aliases ( p) {
277
- write ! ( & mut opts, "-{short} " ) . unwrap ( ) ;
274
+ write ! ( & mut opts, "-{short} " ) . expect ( "writing to String is infallible" ) ;
278
275
}
279
276
for long in utils:: longs_and_visible_aliases ( p) {
280
- write ! ( & mut opts, "--{long} " ) . unwrap ( ) ;
277
+ write ! ( & mut opts, "--{long} " ) . expect ( "writing to String is infallible" ) ;
281
278
}
282
279
for pos in p. get_positionals ( ) {
283
280
if let Some ( vals) = utils:: possible_values ( pos) {
284
281
for value in vals {
285
- write ! ( & mut opts, "{} " , value. get_name( ) ) . unwrap ( ) ;
282
+ write ! ( & mut opts, "{} " , value. get_name( ) )
283
+ . expect ( "writing to String is infallible" ) ;
286
284
}
287
285
} else {
288
- write ! ( & mut opts, "{pos} " ) . unwrap ( ) ;
286
+ write ! ( & mut opts, "{pos} " ) . expect ( "writing to String is infallible" ) ;
289
287
}
290
288
}
291
289
for ( sc, _) in utils:: subcommands ( p) {
292
- write ! ( & mut opts, "{sc} " ) . unwrap ( ) ;
290
+ write ! ( & mut opts, "{sc} " ) . expect ( "writing to String is infallible" ) ;
293
291
}
294
292
opts. pop ( ) ;
295
293
0 commit comments