Tests pass!

This commit is contained in:
Yehuda Katz
2019-07-23 15:22:11 -07:00
parent 01223091ec
commit 5a8e041a48
61 changed files with 1111 additions and 402 deletions

View File

@ -1,4 +1,6 @@
use crate::context::CommandRegistry;
use crate::prelude::*;
use derive_new::new;
use rustyline::completion::Completer;
use rustyline::completion::{self, FilenameCompleter};
@ -7,7 +9,7 @@ use rustyline::line_buffer::LineBuffer;
#[derive(new)]
crate struct NuCompleter {
pub file_completer: FilenameCompleter,
pub commands: indexmap::IndexMap<String, Arc<dyn Command>>,
pub commands: CommandRegistry,
}
impl Completer for NuCompleter {
@ -19,7 +21,7 @@ impl Completer for NuCompleter {
pos: usize,
context: &rustyline::Context,
) -> rustyline::Result<(usize, Vec<completion::Pair>)> {
let commands: Vec<String> = self.commands.keys().cloned().collect();
let commands: Vec<String> = self.commands.names();
let mut completions = self.file_completer.complete(line, pos, context)?.1;

View File

@ -18,7 +18,7 @@ crate struct Helper {
}
impl Helper {
crate fn new(commands: indexmap::IndexMap<String, Arc<dyn Command>>) -> Helper {
crate fn new(commands: CommandRegistry) -> Helper {
Helper {
completer: NuCompleter {
file_completer: FilenameCompleter::new(),