pub struct CommandContext<'a> {
pub raw: &'a str,
pub base_command: String,
pub words: Vec<String>,
pub env_vars: Vec<(String, String)>,
pub redirection: Option<Redirection>,
pub accumulated_env: HashMap<String, String>,
}Expand description
Context for evaluating a single command segment.
Fields§
§raw: &'a strThe full command text of this segment.
base_command: StringThe base command name (e.g. “git”, “ls”, “cargo”).
words: Vec<String>All words in the command (tokenized via shlex).
env_vars: Vec<(String, String)>Leading KEY=VALUE environment variable assignments.
redirection: Option<Redirection>Detected output redirection, if any.
accumulated_env: HashMap<String, String>Environment variables accumulated from prior segments in a compound command
(e.g. export FOO=bar ; git push makes FOO=bar available to the git push segment).
Implementations§
Source§impl<'a> CommandContext<'a>
impl<'a> CommandContext<'a>
Sourcepub fn from_command(raw: &'a str) -> Self
pub fn from_command(raw: &'a str) -> Self
Build a CommandContext from a raw command string.
Sourcepub fn env_satisfies(&self, required: &HashMap<String, String>) -> bool
pub fn env_satisfies(&self, required: &HashMap<String, String>) -> bool
Check if all required env var entries are satisfied.
For each entry, checks the command’s inline env vars first (exact key+value match),
then falls back to the process environment (std::env::var).
Returns true only if ALL entries match. Some entries may come from inline env
and others from the process environment — each is checked independently.
Config values are shell-expanded (~, $HOME, $VAR) before comparison,
since shells expand these in env assignments before they reach the process.
Sourcepub fn has_any_flag(&self, flags: &[&str]) -> bool
pub fn has_any_flag(&self, flags: &[&str]) -> bool
Check if any word matches any of the given flags.