File tree 1 file changed +13
-3
lines changed 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ struct Opt {
13
13
pid : Option < u32 > ,
14
14
15
15
/// Generate shell completions for the given shell.
16
- #[ structopt( long = "completions" ) ]
16
+ #[ structopt( long = "completions" , conflicts_with = "pid" ) ]
17
17
completions : Option < structopt:: clap:: Shell > ,
18
18
19
19
#[ structopt( flatten) ]
@@ -26,8 +26,18 @@ fn main() -> anyhow::Result<()> {
26
26
let opt = Opt :: from_args ( ) ;
27
27
28
28
if let Some ( shell) = opt. completions {
29
- Opt :: clap ( ) . gen_completions_to ( "flamegraph" , shell, & mut std:: io:: stdout ( ) . lock ( ) ) ;
30
- return Ok ( ( ) ) ;
29
+ return match opt. trailing_arguments . is_empty ( ) {
30
+ true => Ok ( Opt :: clap ( ) . gen_completions_to (
31
+ "flamegraph" ,
32
+ shell,
33
+ & mut std:: io:: stdout ( ) . lock ( ) ,
34
+ ) ) ,
35
+ false => {
36
+ return Err ( anyhow ! (
37
+ "command arguments cannot be used with --completions <completions>"
38
+ ) )
39
+ }
40
+ } ;
31
41
}
32
42
33
43
let workload = match ( opt. pid , opt. trailing_arguments . is_empty ( ) ) {
You can’t perform that action at this time.
0 commit comments