mirror of
https://github.com/nushell/nushell
synced 2025-01-09 03:39:03 +00:00
9f85b10fcb
The completion engine maps completion locations to spans on a line, which indicate whther to complete a command name, flag name, argument, and so on. Initial implementation is simplistic, with some rough edges, since it relies heavily on the parser's interpretation. For example du - if asking for completions, `-` is considered a positional argument by the parser, but the user is likely looking for a flag. These scenarios will be addressed in a series of progressive enhancements to the engine.
19 lines
529 B
Rust
19 lines
529 B
Rust
use std::fmt::Debug;
|
|
|
|
/// A combination of an informative parse error, and what has been successfully parsed so far
|
|
#[derive(Debug)]
|
|
pub struct ParseError<T: Debug> {
|
|
/// An informative cause for this parse error
|
|
pub cause: nu_errors::ParseError,
|
|
|
|
/// What has been successfully parsed, if anything
|
|
pub partial: Option<T>,
|
|
}
|
|
|
|
pub type ParseResult<T> = Result<T, ParseError<T>>;
|
|
|
|
impl<T: Debug> From<ParseError<T>> for nu_errors::ShellError {
|
|
fn from(e: ParseError<T>) -> Self {
|
|
e.cause.into()
|
|
}
|
|
}
|