Skip to main content

ShellAction

Struct ShellAction 

Source
pub struct ShellAction { /* private fields */ }
Expand description

A declared command, ready to run as an activity.

Implementations§

Source§

impl ShellAction

Source

pub fn new(command: &str) -> Result<Self, TemplateError>

Parse command into a runnable action.

§Errors

Returns TemplateError when the command is empty, has an unterminated quote or ${, contains a $ naming no parameter, or puts a parameter in program position.

Source

pub const fn with_failure_mode(self, failure_mode: FailureMode) -> Self

Set how a non-zero exit is classified.

Source

pub fn with_environment(self, environment: BTreeMap<String, String>) -> Self

Supply the environment the command runs with.

Additive to nothing: the host’s environment is cleared regardless, so these entries plus [INHERITED_VARIABLE] are the command’s whole environment. An entry named PATH here replaces the inherited one.

Source

pub fn with_working_directory(self, directory: impl Into<PathBuf>) -> Self

Run the command in directory instead of wherever the host happens to be.

Worth setting whenever a command names a relative path. Absent, the command inherits the host process’s working directory, which is a property of how the host was launched and not something a package author can see — so a relative path in a declared command means something the author cannot predict.

Source

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

The parameter names this command references, sorted.

A caller can compare these against an action’s declared parameters to catch a reference to a parameter that does not exist.

Source

pub async fn run( &self, arguments: &BTreeMap<String, Value>, context: &ActivityContext, ) -> Result<ShellOutcome, ActivityFailure>

Run the command with arguments bound to its parameter references.

Cancellation is tree-wide: the command runs in its own process group, and cancelling the activity terminates that whole group rather than only the direct child, so a command that spawned children does not leave them running.

Output is streamed onto context’s transcript seam line by line as the command writes it (see CommandTranscript), so an operator can read what a command step is printing mid-run. The returned ShellOutcome is unaffected: it still carries the command’s complete stdout and stderr.

§Errors

Returns an ActivityFailure when a referenced parameter is missing or unrepresentable (terminal — re-running cannot supply it), when the command cannot be spawned or observed (terminal — the program is absent or unrunnable), when the command is cancelled (terminal), or when it exits non-zero (classified by the action’s FailureMode).

Trait Implementations§

Source§

impl Clone for ShellAction

Source§

fn clone(&self) -> ShellAction

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShellAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more