variable export and entire config system
This commit is contained in:
parent
0931fbdcf0
commit
307101327c
10 changed files with 184 additions and 21 deletions
26
src/stl.rs
26
src/stl.rs
|
|
@ -15,14 +15,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::segment::{Ctr};
|
||||
use crate::str::{get_echo, get_concat};
|
||||
use crate::append::get_append;
|
||||
use crate::func::{FTable, func_declare};
|
||||
use crate::vars::{get_export};
|
||||
use crate::vars::{VTable, get_export};
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
|
||||
pub fn get_stdlib() -> Result<Rc<RefCell<FTable>>, String> {
|
||||
pub fn get_stdlib(conf: Rc<RefCell<VTable>>) -> Result<Rc<RefCell<FTable>>, String> {
|
||||
let ft = Rc::new(RefCell::new(FTable::new()));
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_echo()))) {
|
||||
return Err(s)
|
||||
|
|
@ -33,7 +34,26 @@ pub fn get_stdlib() -> Result<Rc<RefCell<FTable>>, String> {
|
|||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_concat()))) {
|
||||
return Err(s)
|
||||
}
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_export()))) {
|
||||
|
||||
let mut cfg_env = true;
|
||||
match conf.borrow().get(&String::from("CFG_RELISH_ENV")) {
|
||||
None => {
|
||||
println!("CFG_RELISH_ENV not defined. defaulting to ON.")
|
||||
}
|
||||
Some(ctr) => {
|
||||
match (**ctr).clone() {
|
||||
Ctr::String(ref s) => {
|
||||
cfg_env = s.eq("0")
|
||||
}
|
||||
_ => {
|
||||
println!("Invalid value for CFG_RELISH_ENV. must be a string (0 or 1).");
|
||||
println!("Defaulting CFG_RELISH_ENV to ON");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_export(cfg_env)))) {
|
||||
return Err(s)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue