Merge branch 'master' into size

This commit is contained in:
Yehuda Katz
2019-05-26 00:20:01 -07:00
committed by GitHub
24 changed files with 2600 additions and 216 deletions

View File

@ -1,9 +1,13 @@
use crate::prelude::*;
use derive_new::new;
use rustyline::completion::Completer;
use rustyline::completion::{self, FilenameCompleter};
use rustyline::line_buffer::LineBuffer;
#[derive(new)]
crate struct NuCompleter {
pub file_completer: FilenameCompleter,
pub commands: indexmap::IndexMap<String, Arc<dyn Command>>,
}
impl Completer for NuCompleter {
@ -15,10 +19,8 @@ impl Completer for NuCompleter {
pos: usize,
context: &rustyline::Context,
) -> rustyline::Result<(usize, Vec<completion::Pair>)> {
let commands = [
"ps", "ls", "cd", "view", "skip", "take", "select", "reject", "to-array", "where",
"sort-by", "size",
];
let commands: Vec<String> = self.commands.keys().cloned().collect();
let mut completions = self.file_completer.complete(line, pos, context)?.1;

View File

@ -1,5 +1,6 @@
use crate::shell::completer::NuCompleter;
use crate::prelude::*;
use rustyline::completion::{self, Completer, FilenameCompleter};
use rustyline::error::ReadlineError;
use rustyline::highlight::{Highlighter, MatchingBracketHighlighter};
@ -13,10 +14,11 @@ crate struct Helper {
}
impl Helper {
crate fn new() -> Helper {
crate fn new(commands: indexmap::IndexMap<String, Arc<dyn Command>>) -> Helper {
Helper {
completer: NuCompleter {
file_completer: FilenameCompleter::new(),
commands,
},
highlighter: MatchingBracketHighlighter::new(),
hinter: HistoryHinter {},