mirror of
https://github.com/nushell/nushell
synced 2025-01-15 14:44:14 +00:00
contents declaration
This commit is contained in:
parent
6387401041
commit
d9c42eb194
3 changed files with 10 additions and 0 deletions
|
@ -67,6 +67,8 @@ pub fn create_default_context() -> Rc<RefCell<EngineState>> {
|
||||||
working_set.add_decl(sig.predeclare());
|
working_set.add_decl(sig.predeclare());
|
||||||
let sig = Signature::build("stack");
|
let sig = Signature::build("stack");
|
||||||
working_set.add_decl(sig.predeclare());
|
working_set.add_decl(sig.predeclare());
|
||||||
|
let sig = Signature::build("contents");
|
||||||
|
working_set.add_decl(sig.predeclare());
|
||||||
|
|
||||||
working_set.render()
|
working_set.render()
|
||||||
};
|
};
|
||||||
|
|
|
@ -113,6 +113,11 @@ impl EngineState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn print_contents(&self) {
|
||||||
|
let string = String::from_utf8_lossy(&self.file_contents);
|
||||||
|
println!("{}", string);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn find_decl(&self, name: &[u8]) -> Option<DeclId> {
|
pub fn find_decl(&self, name: &[u8]) -> Option<DeclId> {
|
||||||
for scope in self.scope.iter().rev() {
|
for scope in self.scope.iter().rev() {
|
||||||
if let Some(decl_id) = scope.decls.get(name) {
|
if let Some(decl_id) = scope.decls.get(name) {
|
||||||
|
|
|
@ -102,6 +102,9 @@ fn main() -> Result<()> {
|
||||||
} else if s.trim() == "stack" {
|
} else if s.trim() == "stack" {
|
||||||
stack.print_stack();
|
stack.print_stack();
|
||||||
continue;
|
continue;
|
||||||
|
} else if s.trim() == "contents" {
|
||||||
|
engine_state.borrow().print_contents();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (block, delta) = {
|
let (block, delta) = {
|
||||||
|
|
Loading…
Reference in a new issue