mirror of
https://github.com/nushell/nushell.git
synced 2025-05-02 17:14:27 +02:00
contents declaration
This commit is contained in:
parent
6387401041
commit
d9c42eb194
@ -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 New Issue
Block a user