diff options
Diffstat (limited to 'src/compose.rs')
-rw-r--r-- | src/compose.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/compose.rs b/src/compose.rs index 8c4b3ea..3d2a2db 100644 --- a/src/compose.rs +++ b/src/compose.rs @@ -1,8 +1,13 @@ use crate::poem::{read::Readable, recite::Reciteable, Poem}; +pub mod environment; +pub use environment::Environment; use std::fs; use std::path::PathBuf; -pub fn env() { +pub fn env() -> Environment { + // Create a new Environment object, to store some extra shell info + let mut env = Environment::new(); + // Use local repo path if running the debug target let global_rc = if cfg!(debug_assertions) { let mut base = PathBuf::from(env!("CARGO_MANIFEST_DIR")); @@ -17,11 +22,14 @@ pub fn env() { local_rc.push(".dwvshrc"); // Read, read, and recite - rrr(global_rc); - rrr(local_rc); + rrr(global_rc, &mut env); + rrr(local_rc, &mut env); + + // Return the new environment + env } -fn rrr(path: PathBuf) { +fn rrr(path: PathBuf, env: &mut Environment) { let poetry = match fs::read_to_string(&path) { Ok(poetry) => poetry, Err(e) => { @@ -47,8 +55,7 @@ fn rrr(path: PathBuf) { } }; - let mut bins = vec![]; - match poem.recite(&mut bins, None) { + match poem.recite(env, None) { Ok(_) => {} Err(e) => { eprintln!("dwvsh: {}", e.to_string().to_lowercase()); |