@@ -198,7 +198,7 @@ fn complete_arg(
198
198
comp. get_content( ) . to_string_lossy( )
199
199
) )
200
200
. help ( comp. get_help ( ) . cloned ( ) )
201
- . visible ( comp. is_visible ( ) )
201
+ . hide ( comp. is_hide_set ( ) )
202
202
} ) ,
203
203
) ;
204
204
}
@@ -241,7 +241,6 @@ fn complete_arg(
241
241
comp. get_content( ) . to_string_lossy( )
242
242
) )
243
243
. help ( comp. get_help ( ) . cloned ( ) )
244
- . visible ( true )
245
244
} ) ,
246
245
) ;
247
246
} else if let Some ( short) = arg. to_short ( ) {
@@ -271,7 +270,7 @@ fn complete_arg(
271
270
comp. get_content( ) . to_string_lossy( )
272
271
) )
273
272
. help ( comp. get_help ( ) . cloned ( ) )
274
- . visible ( comp. is_visible ( ) )
273
+ . hide ( comp. is_hide_set ( ) )
275
274
} ) ,
276
275
) ;
277
276
} else {
@@ -283,7 +282,7 @@ fn complete_arg(
283
282
comp. get_content( ) . to_string_lossy( )
284
283
) )
285
284
. help ( comp. get_help ( ) . cloned ( ) )
286
- . visible ( comp. is_visible ( ) )
285
+ . hide ( comp. is_hide_set ( ) )
287
286
} ,
288
287
) ) ;
289
288
}
@@ -324,8 +323,8 @@ fn complete_arg(
324
323
}
325
324
}
326
325
}
327
- if completions. iter ( ) . any ( |a| a . is_visible ( ) ) {
328
- completions. retain ( |a| a . is_visible ( ) ) ;
326
+ if completions. iter ( ) . any ( |a| !a . is_hide_set ( ) ) {
327
+ completions. retain ( |a| !a . is_hide_set ( ) ) ;
329
328
}
330
329
331
330
Ok ( completions)
@@ -346,7 +345,7 @@ fn complete_arg_value(
346
345
name. starts_with ( value) . then ( || {
347
346
CompletionCandidate :: new ( OsString :: from ( name) )
348
347
. help ( p. get_help ( ) . cloned ( ) )
349
- . visible ( ! p. is_hide_set ( ) )
348
+ . hide ( p. is_hide_set ( ) )
350
349
} )
351
350
} ) ) ;
352
351
}
@@ -428,20 +427,14 @@ fn complete_path(
428
427
let path = entry. path ( ) ;
429
428
let mut suggestion = pathdiff:: diff_paths ( & path, current_dir) . unwrap_or ( path) ;
430
429
suggestion. push ( "" ) ; // Ensure trailing `/`
431
- completions. push (
432
- CompletionCandidate :: new ( suggestion. as_os_str ( ) . to_owned ( ) )
433
- . help ( None )
434
- . visible ( true ) ,
435
- ) ;
430
+ completions
431
+ . push ( CompletionCandidate :: new ( suggestion. as_os_str ( ) . to_owned ( ) ) . help ( None ) ) ;
436
432
} else {
437
433
let path = entry. path ( ) ;
438
434
if is_wanted ( & path) {
439
435
let suggestion = pathdiff:: diff_paths ( & path, current_dir) . unwrap_or ( path) ;
440
- completions. push (
441
- CompletionCandidate :: new ( suggestion. as_os_str ( ) . to_owned ( ) )
442
- . help ( None )
443
- . visible ( true ) ,
444
- ) ;
436
+ completions
437
+ . push ( CompletionCandidate :: new ( suggestion. as_os_str ( ) . to_owned ( ) ) . help ( None ) ) ;
445
438
}
446
439
}
447
440
}
@@ -476,7 +469,7 @@ fn longs_and_visible_aliases(p: &clap::Command) -> Vec<CompletionCandidate> {
476
469
longs. into_iter ( ) . map ( |s| {
477
470
CompletionCandidate :: new ( format ! ( "--{}" , s) )
478
471
. help ( a. get_help ( ) . cloned ( ) )
479
- . visible ( ! a. is_hide_set ( ) )
472
+ . hide ( a. is_hide_set ( ) )
480
473
} )
481
474
} )
482
475
} )
@@ -494,7 +487,7 @@ fn hidden_longs_aliases(p: &clap::Command) -> Vec<CompletionCandidate> {
494
487
longs. into_iter ( ) . map ( |s| {
495
488
CompletionCandidate :: new ( format ! ( "--{}" , s) )
496
489
. help ( a. get_help ( ) . cloned ( ) )
497
- . visible ( false )
490
+ . hide ( true )
498
491
} )
499
492
} )
500
493
} )
@@ -513,7 +506,7 @@ fn shorts_and_visible_aliases(p: &clap::Command) -> Vec<CompletionCandidate> {
513
506
shorts. into_iter ( ) . map ( |s| {
514
507
CompletionCandidate :: new ( s. to_string ( ) )
515
508
. help ( a. get_help ( ) . cloned ( ) )
516
- . visible ( ! a. is_hide_set ( ) )
509
+ . hide ( a. is_hide_set ( ) )
517
510
} )
518
511
} )
519
512
} )
@@ -546,12 +539,12 @@ fn subcommands(p: &clap::Command) -> Vec<CompletionCandidate> {
546
539
. map ( |s| {
547
540
CompletionCandidate :: new ( s. to_string ( ) )
548
541
. help ( sc. get_about ( ) . cloned ( ) )
549
- . visible ( ! sc. is_hide_set ( ) )
542
+ . hide ( sc. is_hide_set ( ) )
550
543
} )
551
544
. chain ( sc. get_aliases ( ) . map ( |s| {
552
545
CompletionCandidate :: new ( s. to_string ( ) )
553
546
. help ( sc. get_about ( ) . cloned ( ) )
554
- . visible ( false )
547
+ . hide ( true )
555
548
} ) )
556
549
} )
557
550
. collect ( )
@@ -667,8 +660,8 @@ pub struct CompletionCandidate {
667
660
/// Help message with a completion candidate
668
661
help : Option < StyledStr > ,
669
662
670
- /// Whether the completion candidate is visible
671
- visible : bool ,
663
+ /// Whether the completion candidate is hidden
664
+ hidden : bool ,
672
665
}
673
666
674
667
impl CompletionCandidate {
@@ -688,8 +681,8 @@ impl CompletionCandidate {
688
681
}
689
682
690
683
/// Set the visibility of the completion candidate
691
- pub fn visible ( mut self , visible : bool ) -> Self {
692
- self . visible = visible ;
684
+ pub fn hide ( mut self , hidden : bool ) -> Self {
685
+ self . hidden = hidden ;
693
686
self
694
687
}
695
688
@@ -704,7 +697,7 @@ impl CompletionCandidate {
704
697
}
705
698
706
699
/// Get the visibility of the completion candidate
707
- pub fn is_visible ( & self ) -> bool {
708
- self . visible
700
+ pub fn is_hide_set ( & self ) -> bool {
701
+ self . hidden
709
702
}
710
703
}
0 commit comments