Skip to content

Commit

Permalink
fix(complete)!: Rename CustomCompleter to ValueCandidates
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 20, 2024
1 parent 1089073 commit 71c5e27
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions clap_complete/src/engine/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clap::builder::ArgExt;

use super::CompletionCandidate;

/// Extend [`Arg`][clap::Arg] with a [`CustomCompleter`]
/// Extend [`Arg`][clap::Arg] with a [`ValueCandidates`]
///
/// # Example
///
Expand All @@ -23,13 +23,13 @@ use super::CompletionCandidate;
/// }
/// ```
#[derive(Clone)]
pub struct ArgValueCompleter(Arc<dyn CustomCompleter>);
pub struct ArgValueCompleter(Arc<dyn ValueCandidates>);

impl ArgValueCompleter {
/// Create a new `ArgValueCompleter` with a custom completer
pub fn new<C>(completer: C) -> Self
where
C: CustomCompleter + 'static,
C: ValueCandidates + 'static,
{
Self(Arc::new(completer))
}
Expand All @@ -53,14 +53,14 @@ impl ArgExt for ArgValueCompleter {}
/// User-provided completion candidates for an [`Arg`][clap::Arg], see [`ArgValueCompleter`]
///
/// This is useful when predefined value hints are not enough.
pub trait CustomCompleter: Send + Sync {
pub trait ValueCandidates: Send + Sync {
/// All potential candidates for an argument.
///
/// See [`CompletionCandidate`] for more information.
fn candidates(&self) -> Vec<CompletionCandidate>;
}

impl<F> CustomCompleter for F
impl<F> ValueCandidates for F
where
F: Fn() -> Vec<CompletionCandidate> + Send + Sync,
{
Expand Down
2 changes: 1 addition & 1 deletion clap_complete/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ mod custom;
pub use candidate::CompletionCandidate;
pub use complete::complete;
pub use custom::ArgValueCompleter;
pub use custom::CustomCompleter;
pub use custom::ValueCandidates;
4 changes: 2 additions & 2 deletions clap_complete/tests/testsuite/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fs;
use std::path::Path;

use clap::{builder::PossibleValue, Command};
use clap_complete::engine::{ArgValueCompleter, CompletionCandidate, CustomCompleter};
use clap_complete::engine::{ArgValueCompleter, CompletionCandidate, ValueCandidates};
use snapbox::assert_data_eq;

macro_rules! complete {
Expand Down Expand Up @@ -596,7 +596,7 @@ fn suggest_custom_arg_value() {
#[derive(Debug)]
struct MyCustomCompleter {}

impl CustomCompleter for MyCustomCompleter {
impl ValueCandidates for MyCustomCompleter {
fn candidates(&self) -> Vec<CompletionCandidate> {
vec![
CompletionCandidate::new("custom1"),
Expand Down

0 comments on commit 71c5e27

Please sign in to comment.