@@ -5,31 +5,31 @@ use clap::builder::ArgExt;
5
5
6
6
use super :: CompletionCandidate ;
7
7
8
- /// Extend [`Arg`][clap::Arg] with a [`CustomCompleter `]
8
+ /// Extend [`Arg`][clap::Arg] with a [`ValueCandidates `]
9
9
///
10
10
/// # Example
11
11
///
12
12
/// ```rust
13
13
/// use clap::Parser;
14
- /// use clap_complete::engine::{ArgValueCompleter , CompletionCandidate};
14
+ /// use clap_complete::engine::{ArgValueCandidates , CompletionCandidate};
15
15
///
16
16
/// #[derive(Debug, Parser)]
17
17
/// struct Cli {
18
- /// #[arg(long, add = ArgValueCompleter ::new(|| { vec![
18
+ /// #[arg(long, add = ArgValueCandidates ::new(|| { vec![
19
19
/// CompletionCandidate::new("foo"),
20
20
/// CompletionCandidate::new("bar"),
21
21
/// CompletionCandidate::new("baz")] }))]
22
22
/// custom: Option<String>,
23
23
/// }
24
24
/// ```
25
25
#[ derive( Clone ) ]
26
- pub struct ArgValueCompleter ( Arc < dyn CustomCompleter > ) ;
26
+ pub struct ArgValueCandidates ( Arc < dyn ValueCandidates > ) ;
27
27
28
- impl ArgValueCompleter {
29
- /// Create a new `ArgValueCompleter ` with a custom completer
28
+ impl ArgValueCandidates {
29
+ /// Create a new `ArgValueCandidates ` with a custom completer
30
30
pub fn new < C > ( completer : C ) -> Self
31
31
where
32
- C : CustomCompleter + ' static ,
32
+ C : ValueCandidates + ' static ,
33
33
{
34
34
Self ( Arc :: new ( completer) )
35
35
}
@@ -42,25 +42,25 @@ impl ArgValueCompleter {
42
42
}
43
43
}
44
44
45
- impl std:: fmt:: Debug for ArgValueCompleter {
45
+ impl std:: fmt:: Debug for ArgValueCandidates {
46
46
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
47
47
f. write_str ( type_name :: < Self > ( ) )
48
48
}
49
49
}
50
50
51
- impl ArgExt for ArgValueCompleter { }
51
+ impl ArgExt for ArgValueCandidates { }
52
52
53
- /// User-provided completion candidates for an [`Arg`][clap::Arg], see [`ArgValueCompleter `]
53
+ /// User-provided completion candidates for an [`Arg`][clap::Arg], see [`ArgValueCandidates `]
54
54
///
55
55
/// This is useful when predefined value hints are not enough.
56
- pub trait CustomCompleter : Send + Sync {
56
+ pub trait ValueCandidates : Send + Sync {
57
57
/// All potential candidates for an argument.
58
58
///
59
59
/// See [`CompletionCandidate`] for more information.
60
60
fn candidates ( & self ) -> Vec < CompletionCandidate > ;
61
61
}
62
62
63
- impl < F > CustomCompleter for F
63
+ impl < F > ValueCandidates for F
64
64
where
65
65
F : Fn ( ) -> Vec < CompletionCandidate > + Send + Sync ,
66
66
{
0 commit comments