|
@ -2,9 +2,11 @@ use crate::builtins::BuiltinConfig; |
|
|
use crate::prompt::Prompt;
|
|
|
use crate::prompt::Prompt;
|
|
|
use colored::Colorize;
|
|
|
use colored::Colorize;
|
|
|
use execute::interpret;
|
|
|
use execute::interpret;
|
|
|
|
|
|
use rustyline::completion::FilenameCompleter;
|
|
|
use rustyline::config::Configurer;
|
|
|
use rustyline::config::Configurer;
|
|
|
use rustyline::error::ReadlineError;
|
|
|
use rustyline::error::ReadlineError;
|
|
|
use rustyline::{Editor, Result};
|
|
|
|
|
|
|
|
|
use rustyline::{CompletionType, Config, Editor, Result};
|
|
|
|
|
|
use rustyline_derive::{Completer, Helper, Highlighter, Hinter, Validator};
|
|
|
use whoami::username;
|
|
|
use whoami::username;
|
|
|
|
|
|
|
|
|
mod builtins;
|
|
|
mod builtins;
|
|
@ -14,13 +16,28 @@ mod parse; |
|
|
mod preprocess;
|
|
|
mod preprocess;
|
|
|
mod prompt;
|
|
|
mod prompt;
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Completer, Helper, Highlighter, Hinter, Validator)]
|
|
|
|
|
|
struct EditorHelper {
|
|
|
|
|
|
#[rustyline(Completer)]
|
|
|
|
|
|
completer: FilenameCompleter,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
|
|
fn main() -> Result<()> {
|
|
|
let (ctrlc_send, ctrlc_recv) = crossbeam_channel::unbounded::<()>();
|
|
|
let (ctrlc_send, ctrlc_recv) = crossbeam_channel::unbounded::<()>();
|
|
|
let _ = ctrlc::set_handler(move || {
|
|
|
let _ = ctrlc::set_handler(move || {
|
|
|
let _ = ctrlc_send.send(());
|
|
|
let _ = ctrlc_send.send(());
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
let mut rl = Editor::<()>::new()?;
|
|
|
|
|
|
|
|
|
let config = Config::builder()
|
|
|
|
|
|
.completion_type(CompletionType::List)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
let helper = EditorHelper {
|
|
|
|
|
|
completer: FilenameCompleter::new(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let mut rl = Editor::with_config(config)?;
|
|
|
|
|
|
rl.set_helper(Some(helper));
|
|
|
rl.set_auto_add_history(true);
|
|
|
rl.set_auto_add_history(true);
|
|
|
|
|
|
|
|
|
let mut prompt = Prompt::new();
|
|
|
let mut prompt = Prompt::new();
|
|
|