Skip to content

Commit 2d23c06

Browse files
committed
fix(complete)!: Rename ArgValueCompleter to ArgValueCandidates
1 parent 71c5e27 commit 2d23c06

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

clap_complete/src/engine/complete.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::ffi::OsString;
33

44
use clap_lex::OsStrExt as _;
55

6-
use super::ArgValueCompleter;
6+
use super::ArgValueCandidates;
77
use super::CompletionCandidate;
88

99
/// Complete the given command, shell-agnostic
@@ -270,7 +270,7 @@ fn complete_arg_value(
270270
Err(value_os) => value_os,
271271
};
272272

273-
if let Some(completer) = arg.get::<ArgValueCompleter>() {
273+
if let Some(completer) = arg.get::<ArgValueCandidates>() {
274274
values.extend(complete_custom_arg_value(value_os, completer));
275275
} else if let Some(possible_values) = possible_values(arg) {
276276
if let Ok(value) = value {
@@ -394,7 +394,7 @@ fn complete_path(
394394

395395
fn complete_custom_arg_value(
396396
value: &OsStr,
397-
completer: &ArgValueCompleter,
397+
completer: &ArgValueCandidates,
398398
) -> Vec<CompletionCandidate> {
399399
debug!("complete_custom_arg_value: completer={completer:?}, value={value:?}");
400400

clap_complete/src/engine/custom.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ use super::CompletionCandidate;
1111
///
1212
/// ```rust
1313
/// use clap::Parser;
14-
/// use clap_complete::engine::{ArgValueCompleter, CompletionCandidate};
14+
/// use clap_complete::engine::{ArgValueCandidates, CompletionCandidate};
1515
///
1616
/// #[derive(Debug, Parser)]
1717
/// struct Cli {
18-
/// #[arg(long, add = ArgValueCompleter::new(|| { vec![
18+
/// #[arg(long, add = ArgValueCandidates::new(|| { vec![
1919
/// CompletionCandidate::new("foo"),
2020
/// CompletionCandidate::new("bar"),
2121
/// CompletionCandidate::new("baz")] }))]
2222
/// custom: Option<String>,
2323
/// }
2424
/// ```
2525
#[derive(Clone)]
26-
pub struct ArgValueCompleter(Arc<dyn ValueCandidates>);
26+
pub struct ArgValueCandidates(Arc<dyn ValueCandidates>);
2727

28-
impl ArgValueCompleter {
29-
/// Create a new `ArgValueCompleter` with a custom completer
28+
impl ArgValueCandidates {
29+
/// Create a new `ArgValueCandidates` with a custom completer
3030
pub fn new<C>(completer: C) -> Self
3131
where
3232
C: ValueCandidates + 'static,
@@ -42,15 +42,15 @@ impl ArgValueCompleter {
4242
}
4343
}
4444

45-
impl std::fmt::Debug for ArgValueCompleter {
45+
impl std::fmt::Debug for ArgValueCandidates {
4646
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4747
f.write_str(type_name::<Self>())
4848
}
4949
}
5050

51-
impl ArgExt for ArgValueCompleter {}
51+
impl ArgExt for ArgValueCandidates {}
5252

53-
/// User-provided completion candidates for an [`Arg`][clap::Arg], see [`ArgValueCompleter`]
53+
/// User-provided completion candidates for an [`Arg`][clap::Arg], see [`ArgValueCandidates`]
5454
///
5555
/// This is useful when predefined value hints are not enough.
5656
pub trait ValueCandidates: Send + Sync {

clap_complete/src/engine/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ mod custom;
88

99
pub use candidate::CompletionCandidate;
1010
pub use complete::complete;
11-
pub use custom::ArgValueCompleter;
11+
pub use custom::ArgValueCandidates;
1212
pub use custom::ValueCandidates;

clap_complete/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub use command::CompleteArgs;
8080
pub use command::CompleteCommand;
8181
#[doc(inline)]
8282
#[cfg(feature = "unstable-dynamic")]
83-
pub use engine::ArgValueCompleter;
83+
pub use engine::ArgValueCandidates;
8484
#[doc(inline)]
8585
#[cfg(feature = "unstable-dynamic")]
8686
pub use engine::CompletionCandidate;

clap_complete/tests/testsuite/engine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fs;
44
use std::path::Path;
55

66
use clap::{builder::PossibleValue, Command};
7-
use clap_complete::engine::{ArgValueCompleter, CompletionCandidate, ValueCandidates};
7+
use clap_complete::engine::{ArgValueCandidates, CompletionCandidate, ValueCandidates};
88
use snapbox::assert_data_eq;
99

1010
macro_rules! complete {
@@ -609,7 +609,7 @@ fn suggest_custom_arg_value() {
609609
let mut cmd = Command::new("dynamic").arg(
610610
clap::Arg::new("custom")
611611
.long("custom")
612-
.add::<ArgValueCompleter>(ArgValueCompleter::new(MyCustomCompleter {})),
612+
.add::<ArgValueCandidates>(ArgValueCandidates::new(MyCustomCompleter {})),
613613
);
614614

615615
assert_data_eq!(

0 commit comments

Comments
 (0)