[][src]Struct wf2_core::context::Context

pub struct Context {
    pub recipe: RecipeKinds,
    pub cwd: PathBuf,
    pub run_mode: RunMode,
    pub name: String,
    pub domains: Vec<String>,
    pub term: Term,
    pub pv: Option<String>,
    pub npm_path: PathBuf,
    pub php_version: PHP,
    pub config_path: Option<PathBuf>,
    pub env: Option<Value>,
    pub file_prefix: PathBuf,
    pub overrides: Option<Value>,
    pub debug: bool,
    pub uid: u32,
    pub gid: u32,
    pub scripts: Option<Scripts>,
}

The Context will be given to all recipes when they are trying to resolve tasks.

Examples

Context has default implementations for every field for maximum flexibility

use wf2_core::context::Context;
use wf2_core::recipes::recipe_kinds::RecipeKinds;
use wf2_core::php::PHP;

let ctx = Context::default();

assert_eq!(ctx.recipe, RecipeKinds::M2);
assert_eq!(ctx.php_version, PHP::SevenThree);

You can also create a context directly from a file

let ctx = Context::new_from_file("../fixtures/config_01.yaml")?;

assert_eq!(ctx.recipe, RecipeKinds::M2);
assert_eq!(ctx.php_version, PHP::SevenThree);
assert_eq!(ctx.domains, vec![String::from("acme.m2")]);
assert_eq!(ctx.npm_path, PathBuf::from("app/code/frontend/Acme/design"));

Fields

recipe: RecipeKindscwd: PathBufrun_mode: RunModename: Stringdomains: Vec<String>term: Termpv: Option<String>npm_path: PathBufphp_version: PHPconfig_path: Option<PathBuf>env: Option<Value>file_prefix: PathBufoverrides: Option<Value>debug: booluid: u32gid: u32scripts: Option<Scripts>

Methods

impl Context[src]

pub fn new_from_file(path: impl Into<String>) -> Result<Context, FromFileError>[src]

pub fn new_from_str(yaml_str: &str) -> Result<Context, FromFileError>[src]

pub fn default_domain(&self) -> String[src]

pub fn domains(&self) -> String[src]

pub fn get_context_name(cwd: &PathBuf) -> String[src]

pub fn merge(&mut self, other: ContextOverrides) -> &mut Self[src]

pub fn file_path(&self, filename: &str) -> PathBuf[src]

Trait Implementations

impl Clone for Context[src]

impl Default for Context[src]

impl Debug for Context[src]

impl<'de> Deserialize<'de> for Context[src]

impl FromFile for Context[src]

Auto Trait Implementations

impl Send for Context

impl Sync for Context

impl Unpin for Context

impl UnwindSafe for Context

impl RefUnwindSafe for Context

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

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

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,