mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 19:17:44 +02:00
A real parser (lalrpop)
This commit is contained in:
@ -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,7 @@ 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",
|
||||
];
|
||||
let commands: Vec<String> = self.commands.keys().cloned().collect();
|
||||
|
||||
let mut completions = self.file_completer.complete(line, pos, context)?.1;
|
||||
|
||||
|
@ -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 {},
|
||||
|
Reference in New Issue
Block a user