use std::collections::HashMap; /// Record the shell state /// /// The [Environment] struct keeps track of various fields, all relating to the /// shell state. The environment is the first thing setup at the beginning of /// the shell, and is maintained throughout the lifetime of the process. /// /// Both [crate::Poem]::read() and [crate::Poem]::recite() rely on this struct /// for various functions and features. /// /// # Fields /// aliases - A table of aliases, set by the user using the built-in 'alias' /// bins - A lookup table for +x files, constructed from the $PATH /// cs - Indication of callstack level, helpful for recursively dealing with /// aliases /// fc - Force the capture of stdout (for internal poems) /// /// # Examples /// ``` /// fn main() -> Result<(), io::Error> { /// let mut env = compose::env(); /// let poem = Poem::read("alias", &mut env)?; /// poem.recite(&mut env)?; /// () /// } /// ``` #[derive(Debug, PartialEq, Eq, Clone)] pub struct Environment { pub aliases: HashMap, pub bins: Vec, pub cs: u8, pub fc: bool, } impl Environment { /// Initialize an [Environment] struct with the default values pub fn new() -> Self { Environment { aliases: HashMap::new(), bins: Vec::new(), cs: 0, fc: false, } } }