pub struct ShellAction { /* private fields */ }Expand description
A declared command, ready to run as an activity.
Implementations§
Source§impl ShellAction
impl ShellAction
Sourcepub fn new(command: &str) -> Result<Self, TemplateError>
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.
Sourcepub const fn with_failure_mode(self, failure_mode: FailureMode) -> Self
pub const fn with_failure_mode(self, failure_mode: FailureMode) -> Self
Set how a non-zero exit is classified.
Sourcepub fn with_environment(self, environment: BTreeMap<String, String>) -> Self
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.
Sourcepub fn with_working_directory(self, directory: impl Into<PathBuf>) -> Self
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.
Sourcepub fn referenced_parameters(&self) -> Vec<String>
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.
Sourcepub async fn run(
&self,
arguments: &BTreeMap<String, Value>,
context: &ActivityContext,
) -> Result<ShellOutcome, ActivityFailure>
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.
§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
impl Clone for ShellAction
Source§fn clone(&self) -> ShellAction
fn clone(&self) -> ShellAction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ShellAction
impl RefUnwindSafe for ShellAction
impl Send for ShellAction
impl Sync for ShellAction
impl Unpin for ShellAction
impl UnsafeUnpin for ShellAction
impl UnwindSafe for ShellAction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request