pub struct Config {
pub default: Option<Spec>,
pub empty_line: Option<Spec>,
pub initial_word: Option<Spec>,
pub current_completion_options: Option<GenerationOptions>,
/* private fields */
}Expand description
Encapsulates the shell’s programmable command completion configuration.
Fields§
§default: Option<Spec>Optionally, a completion spec to be used as a default, when earlier matches yield no candidates.
empty_line: Option<Spec>Optionally, a completion spec to be used when the command line is empty.
initial_word: Option<Spec>Optionally, a completion spec to be used for the initial word of a command line.
current_completion_options: Option<GenerationOptions>Optionally, stores the current completion options in effect. May be mutated while a completion generation is in-flight.
Implementations§
Source§impl Config
impl Config
Sourcepub fn remove(&mut self, name: &str) -> bool
pub fn remove(&mut self, name: &str) -> bool
Ensures the named completion spec is no longer registered; returns whether a removal operation was required.
§Arguments
name- The name of the completion spec to remove.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &Spec)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &Spec)>
Returns an iterator over the completion specs.
Sourcepub fn get(&self, name: &str) -> Option<&Spec>
pub fn get(&self, name: &str) -> Option<&Spec>
If present, returns the completion spec for the command of the given name.
§Arguments
name- The name of the command.
Sourcepub fn set(&mut self, name: &str, spec: Spec)
pub fn set(&mut self, name: &str, spec: Spec)
If present, sets the provided completion spec to be associated with the command of the given name.
§Arguments
name- The name of the command.spec- The completion spec to associate with the command.
Sourcepub fn get_or_add_mut(&mut self, name: &str) -> &mut Spec
pub fn get_or_add_mut(&mut self, name: &str) -> &mut Spec
Returns a mutable reference to the completion spec for the command of the given name; if the command already was associated with a spec, returns a reference to that existing spec. Otherwise registers a new default spec and returns a mutable reference to it.
§Arguments
name- The name of the command.
Sourcepub async fn get_completions(
&self,
shell: &mut Shell,
input: &str,
position: usize,
) -> Result<Completions, Error>
pub async fn get_completions( &self, shell: &mut Shell, input: &str, position: usize, ) -> Result<Completions, Error>
Generates completions for the given input line and cursor position.
§Arguments
shell- The shell instance to use for completion generation.input- The input line for which completions are being generated.position- The 0-based index of the cursor in the input line.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more