pub struct Env {
pub home: PathBuf,
pub config_dir: PathBuf,
pub config_file: PathBuf,
pub state_dir: PathBuf,
pub cwd: PathBuf,
pub session_cookie: Option<String>,
}Expand description
Where the tool reads and writes, and where it was invoked from.
Fields§
§home: PathBufThe user’s home directory, used to expand a leading ~ in templates.
config_dir: PathBufThe directory holding config.yaml and the base directory.
config_file: PathBufThe configuration file itself. Absolute, even when --config named a
relative path.
state_dir: PathBufWhere cached answers are kept.
cwd: PathBufThe directory the command was invoked from.
A session cookie supplied through the environment, which takes precedence over the one in the configuration file.
Implementations§
Source§impl Env
impl Env
Sourcepub fn capture(config_override: Option<&Path>) -> Result<Self, EnvError>
pub fn capture(config_override: Option<&Path>) -> Result<Self, EnvError>
Captures the environment, optionally overriding the configuration file.
The configuration directory is the first of: the parent of an explicit
--config file, $AOC_CONFIG_DIR, $XDG_CONFIG_HOME/aoc, or
~/.config/aoc. A relative --config path is resolved against the
current directory first, so both it and the directory derived from it
name a real place rather than depending on where the process later
looks from.
§Errors
Returns EnvError if the home or current directory cannot be
determined.