We split off the evaluation engine part of nu-cli into its own crate. This helps improve build times for nu-cli by 17% in my tests. It also helps us see a bit better what's the core engine portion vs the part specific to the interactive CLI piece. There's more than can be done here, but I think it's a good start in the right direction.
38 lines
787 B
Rust
38 lines
787 B
Rust
pub(crate) mod command;
|
|
pub(crate) mod engine;
|
|
pub(crate) mod flag;
|
|
pub(crate) mod matchers;
|
|
pub(crate) mod path;
|
|
|
|
use matchers::Matcher;
|
|
use nu_engine::EvaluationContext;
|
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
pub struct Suggestion {
|
|
pub display: String,
|
|
pub replacement: String,
|
|
}
|
|
|
|
pub struct CompletionContext<'a>(&'a EvaluationContext);
|
|
|
|
impl<'a> CompletionContext<'a> {
|
|
pub fn new(a: &'a EvaluationContext) -> CompletionContext<'a> {
|
|
CompletionContext(a)
|
|
}
|
|
}
|
|
|
|
impl<'a> AsRef<EvaluationContext> for CompletionContext<'a> {
|
|
fn as_ref(&self) -> &EvaluationContext {
|
|
self.0
|
|
}
|
|
}
|
|
|
|
pub trait Completer {
|
|
fn complete(
|
|
&self,
|
|
ctx: &CompletionContext<'_>,
|
|
partial: &str,
|
|
matcher: &dyn Matcher,
|
|
) -> Vec<Suggestion>;
|
|
}
|