pub struct Completion {
pub words: Vec<String>,
pub word_index: usize,
pub line: String,
pub cursor_index: usize,
pub completion_type: CompletionType,
pub key: char,
}Expand description
A completion request. ref.
Fields§
§words: Vec<String>An array of all the words in the command line, including the command itself. Corresponds to COMP_WORDS.
word_index: usizeThe index of the word in words that is currently being completed. Corresponds to COMP_CWORD.
line: StringThe current command line. Corresponds to COMP_LINE.
cursor_index: usizeThe index of the current cursor position relative to the beginning of the current command. Corresponds to COMP_POINT.
completion_type: CompletionTypeThe type of completion attempted. Corresponds to COMP_TYPE.
key: charThe key (or final key of a key sequence) used to invoke the current completion function. Corresponds to COMP_KEY.
Implementations§
Source§impl Completion
impl Completion
Sourcepub fn init() -> Result<Option<Self>, CompletersError>
pub fn init() -> Result<Option<Self>, CompletersError>
Construct a Completion object from command line arguments and envs. If COMPLETE environment variable:
- Is not set, or set to
0or empty, returnNone. - Is set to
1, return aCompletionobject. - Is set to
bash/nu/nushell, generate shell code and exit successfully.
§Errors
If COMPLETE is set to any other value, return CompletersError::UnrecognizedEnvVar; If generate fails, return ShellCodeError.
Sourcepub fn from_args(args: Vec<String>) -> Result<Self, CompletersError>
pub fn from_args(args: Vec<String>) -> Result<Self, CompletersError>
Constructs a Completion object from the arguments, without the first argument (the program name).
§Errors
Errors if provided args could not be parsed successfully.
Sourcepub fn generate_bash() -> Result<String, ShellCodeError>
pub fn generate_bash() -> Result<String, ShellCodeError>
Generate Bash completion code.
§Errors
If the program name cannot be determined or is not a valid identifier in Bash, return ShellCodeError::Encoding. If IO error occurs, return ShellCodeError::IO.
Sourcepub fn generate_nu() -> Result<String, ShellCodeError>
pub fn generate_nu() -> Result<String, ShellCodeError>
Generate Nushell completion code.
§Errors
Errors if failed to resolve name and path of current executable.
Trait Implementations§
Source§impl Clone for Completion
impl Clone for Completion
Source§fn clone(&self) -> Completion
fn clone(&self) -> Completion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more