added env function and test
This commit is contained in:
parent
79184b18ef
commit
f22d807b57
5 changed files with 55 additions and 1 deletions
|
|
@ -189,3 +189,24 @@ pub fn isset_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const ENV_DOCSTRING: &str = "takes no arguments
|
||||
prints out all available symbols and their associated values";
|
||||
|
||||
pub fn env_callback(_ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
let mut functions = vec![];
|
||||
println!("VARIABLES:");
|
||||
for (name, val) in syms.iter() {
|
||||
match val.value {
|
||||
ValueType::VarForm(_) => {
|
||||
println!(" {}: {}", &name, val.value);
|
||||
},
|
||||
_ => functions.push(name.clone()),
|
||||
}
|
||||
}
|
||||
println!("FUNCTIONS:");
|
||||
for func in functions {
|
||||
println!(" {}", func);
|
||||
}
|
||||
Ok(Ctr::None)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue