2021-09-03 00:58:15 +02:00
|
|
|
use std::{cell::RefCell, rc::Rc};
|
|
|
|
|
|
|
|
use nu_protocol::{
|
|
|
|
engine::{EngineState, StateWorkingSet},
|
2021-10-01 23:53:13 +02:00
|
|
|
Signature,
|
2021-09-03 00:58:15 +02:00
|
|
|
};
|
|
|
|
|
2021-10-02 04:59:11 +02:00
|
|
|
use crate::*;
|
2021-09-03 00:58:15 +02:00
|
|
|
|
|
|
|
pub fn create_default_context() -> Rc<RefCell<EngineState>> {
|
|
|
|
let engine_state = Rc::new(RefCell::new(EngineState::new()));
|
|
|
|
let delta = {
|
|
|
|
let engine_state = engine_state.borrow();
|
|
|
|
let mut working_set = StateWorkingSet::new(&*engine_state);
|
|
|
|
|
|
|
|
working_set.add_decl(Box::new(Alias));
|
2021-10-01 07:11:49 +02:00
|
|
|
working_set.add_decl(Box::new(Benchmark));
|
2021-09-03 00:58:15 +02:00
|
|
|
working_set.add_decl(Box::new(BuildString));
|
|
|
|
working_set.add_decl(Box::new(Def));
|
2021-09-03 06:01:45 +02:00
|
|
|
working_set.add_decl(Box::new(Do));
|
2021-10-01 07:11:49 +02:00
|
|
|
working_set.add_decl(Box::new(Each));
|
|
|
|
working_set.add_decl(Box::new(External));
|
|
|
|
working_set.add_decl(Box::new(For));
|
|
|
|
working_set.add_decl(Box::new(From));
|
|
|
|
working_set.add_decl(Box::new(FromJson));
|
2021-10-02 04:59:11 +02:00
|
|
|
working_set.add_decl(Box::new(Get));
|
2021-10-01 23:53:13 +02:00
|
|
|
working_set.add_decl(Box::new(Help));
|
2021-10-01 07:11:49 +02:00
|
|
|
working_set.add_decl(Box::new(If));
|
2021-09-03 04:15:01 +02:00
|
|
|
working_set.add_decl(Box::new(Length));
|
2021-10-01 07:11:49 +02:00
|
|
|
working_set.add_decl(Box::new(Let));
|
|
|
|
working_set.add_decl(Box::new(LetEnv));
|
|
|
|
working_set.add_decl(Box::new(Lines));
|
2021-09-10 03:06:44 +02:00
|
|
|
working_set.add_decl(Box::new(Ls));
|
2021-09-26 00:59:18 +02:00
|
|
|
working_set.add_decl(Box::new(Module));
|
2021-10-01 23:53:13 +02:00
|
|
|
working_set.add_decl(Box::new(Ps));
|
2021-10-01 08:53:47 +02:00
|
|
|
working_set.add_decl(Box::new(Sys));
|
2021-09-10 04:27:12 +02:00
|
|
|
working_set.add_decl(Box::new(Table));
|
2021-10-01 07:11:49 +02:00
|
|
|
working_set.add_decl(Box::new(Use));
|
|
|
|
working_set.add_decl(Box::new(Where));
|
2021-10-02 04:59:11 +02:00
|
|
|
working_set.add_decl(Box::new(Wrap));
|
2021-09-23 21:03:08 +02:00
|
|
|
|
2021-09-14 06:59:46 +02:00
|
|
|
// This is a WIP proof of concept
|
|
|
|
working_set.add_decl(Box::new(ListGitBranches));
|
|
|
|
working_set.add_decl(Box::new(Git));
|
|
|
|
working_set.add_decl(Box::new(GitCheckout));
|
|
|
|
|
2021-09-03 00:58:15 +02:00
|
|
|
let sig = Signature::build("exit");
|
|
|
|
working_set.add_decl(sig.predeclare());
|
|
|
|
let sig = Signature::build("vars");
|
|
|
|
working_set.add_decl(sig.predeclare());
|
|
|
|
let sig = Signature::build("decls");
|
|
|
|
working_set.add_decl(sig.predeclare());
|
|
|
|
let sig = Signature::build("blocks");
|
|
|
|
working_set.add_decl(sig.predeclare());
|
|
|
|
let sig = Signature::build("stack");
|
|
|
|
working_set.add_decl(sig.predeclare());
|
2021-09-25 18:28:15 +02:00
|
|
|
let sig = Signature::build("contents");
|
|
|
|
working_set.add_decl(sig.predeclare());
|
2021-09-03 00:58:15 +02:00
|
|
|
|
|
|
|
working_set.render()
|
|
|
|
};
|
|
|
|
|
|
|
|
{
|
|
|
|
EngineState::merge_delta(&mut *engine_state.borrow_mut(), delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
engine_state
|
|
|
|
}
|