pub struct Spec {
pub options: GenerationOptions,
pub actions: Vec<CompleteAction>,
pub glob_pattern: Option<String>,
pub word_list: Option<String>,
pub function_name: Option<String>,
pub command: Option<String>,
pub filter_pattern: Option<String>,
pub prefix: Option<String>,
pub suffix: Option<String>,
}Expand description
Encapsulates a command completion specification; provides policy for how to generate completions for a given input.
Fields§
§options: GenerationOptionsOptions to use for completion.
actions: Vec<CompleteAction>Actions to take to generate completions.
glob_pattern: Option<String>Optionally, a glob pattern whose expansion will be used as completions.
word_list: Option<String>Optionally, a list of words to use as completions.
function_name: Option<String>Optionally, the name of a shell function to invoke to generate completions.
command: Option<String>Optionally, the name of a command to execute to generate completions.
filter_pattern: Option<String>Optionally, a pattern to filter completions (complete -X), as given:
candidates it matches are removed, or, if it starts with a ! (that
doesn’t start an extglob pattern), those it doesn’t match.
prefix: Option<String>Optionally, provides a prefix to be prepended to all completion candidates.
suffix: Option<String>Optionally, provides a suffix to be appended to all completion candidates.
Implementations§
Source§impl Spec
impl Spec
Sourcepub async fn generate(
&self,
shell: &mut Shell<impl ShellExtensions>,
word: &str,
) -> Result<Vec<String>, Error>
pub async fn generate( &self, shell: &mut Shell<impl ShellExtensions>, word: &str, ) -> Result<Vec<String>, Error>
Generates this spec’s completion candidates for word, a word on its
own (not part of a line being completed), as the compgen builtin
does: with any fallbacks its options ask for added, and like bash,
in the order generated (sorting is for showing them to a user). A
completion function or command run for word is told, like bash’s,
about an empty line being completed for compgen.
This doesn’t start a completion in progress, so the compopt builtin
can’t change the options applied to the candidates. Like bash, a
completion function that asks for completion to restart generates no
candidates.
§Arguments
shell- The shell instance to use for completion generation.word- The word to generate candidates for, as typed (with any quoting).
§Errors
Returns an error if running the completion generator fails, for example when a completion function or command cannot be executed, or when globbing or word expansion fails.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Spec
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Spec
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Spec
impl RefUnwindSafe for Spec
impl Send for Spec
impl Sync for Spec
impl Unpin for Spec
impl UnsafeUnpin for Spec
impl UnwindSafe for Spec
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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