skill_executor/
context.rs1use std::collections::HashMap;
2use std::path::PathBuf;
3
4#[derive(Debug, Clone)]
5pub struct ExecutionContext {
6 pub working_dir: PathBuf,
7 pub env_vars: HashMap<String, String>,
8 pub user_input: Option<String>,
9}
10
11impl ExecutionContext {
12 pub fn new(working_dir: PathBuf) -> Self {
13 Self {
14 working_dir,
15 env_vars: std::env::vars().collect(),
16 user_input: None,
17 }
18 }
19
20 pub fn with_env(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
21 self.env_vars.insert(key.into(), value.into());
22 self
23 }
24
25 pub fn with_user_input(mut self, input: impl Into<String>) -> Self {
26 self.user_input = Some(input.into());
27 self
28 }
29
30 pub fn default() -> Self {
31 Self::new(std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")))
32 }
33}
34
35impl Default for ExecutionContext {
36 fn default() -> Self {
37 Self::default()
38 }
39}