Context

Struct Context 

Source
pub struct Context {
    pub working_dir: PathBuf,
    pub config_path: Option<PathBuf>,
    pub vars: HashMap<String, String>,
    pub interpreter: Vec<String>,
    pub task_stack: Vec<String>,
    pub verbosity: Verbosity,
}
Expand description

Execution context that tracks state during task execution

Fields§

§working_dir: PathBuf

Current working directory

§config_path: Option<PathBuf>

Configuration file path

§vars: HashMap<String, String>

Variables (from options, args, set-environment, etc.)

§interpreter: Vec<String>

Custom interpreter (e.g., [“bash”, “-c”])

§task_stack: Vec<String>

Stack of tasks being executed (for detecting recursion)

§verbosity: Verbosity

Verbosity level

Implementations§

Source§

impl Context

Source

pub fn new() -> Self

Create a new context with default settings

Source

pub fn with_working_dir(self, dir: PathBuf) -> Self

Create a context with a specific working directory

Source

pub fn with_config_path(self, path: PathBuf) -> Self

Set the configuration file path

Source

pub fn with_vars(self, vars: HashMap<String, String>) -> Self

Set variables

Source

pub fn set_var(&mut self, key: String, value: String)

Set a single variable

Source

pub fn get_var(&self, key: &str) -> Option<&String>

Get a variable value

Source

pub fn with_interpreter(self, interpreter: Vec<String>) -> Self

Set the interpreter

Source

pub fn with_verbosity(self, verbosity: Verbosity) -> Self

Set verbosity level

Source

pub fn push_task(&mut self, task_name: String)

Push a task onto the execution stack

Source

pub fn pop_task(&mut self) -> Option<String>

Pop a task from the execution stack

Source

pub fn is_task_in_stack(&self, task_name: &str) -> bool

Check if a task is in the execution stack (detect recursion)

Source

pub fn current_task(&self) -> Option<&String>

Get the current task name (top of stack)

Source

pub fn task_names(&self) -> Vec<String>

Get all task names in the stack

Source

pub fn config_dir(&self) -> PathBuf

Get the directory for the config file (or current dir)

Source

pub fn print_info(&self, message: &str)

Print info message

Source

pub fn print_error(&self, message: &str)

Print error message

Source

pub fn print_debug(&self, message: &str)

Print debug message (only in verbose mode)

Source

pub fn print_task_start(&self, task_name: &str)

Print task start message

Source

pub fn print_task_complete(&self, task_name: &str)

Print task complete message

Source

pub fn print_task_skip(&self, task_name: &str, reason: &str)

Print task skip message

Trait Implementations§

Source§

impl Default for Context

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.