Trait nu_plugin_engine::PluginExecutionContext

source ·
pub trait PluginExecutionContext: Send + Sync {
Show 13 methods // Required methods fn span(&self) -> Span; fn ctrlc(&self) -> Option<&Arc<AtomicBool>>; fn pipeline_externals_state(&self) -> Option<&Arc<(AtomicU32, AtomicU32)>>; fn get_config(&self) -> Result<Config, ShellError>; fn get_plugin_config(&self) -> Result<Option<Value>, ShellError>; fn get_env_var(&self, name: &str) -> Result<Option<Value>, ShellError>; fn get_env_vars(&self) -> Result<HashMap<String, Value>, ShellError>; fn get_current_dir(&self) -> Result<Spanned<String>, ShellError>; fn add_env_var( &mut self, name: String, value: Value ) -> Result<(), ShellError>; fn get_help(&self) -> Result<Spanned<String>, ShellError>; fn get_span_contents( &self, span: Span ) -> Result<Spanned<Vec<u8>>, ShellError>; fn eval_closure( &self, closure: Spanned<Closure>, positional: Vec<Value>, input: PipelineData, redirect_stdout: bool, redirect_stderr: bool ) -> Result<PipelineData, ShellError>; fn boxed(&self) -> Box<dyn PluginExecutionContext>;
}
Expand description

Object safe trait for abstracting operations required of the plugin context.

Required Methods§

source

fn span(&self) -> Span

A span pointing to the command being executed

source

fn ctrlc(&self) -> Option<&Arc<AtomicBool>>

The interrupt signal, if present

source

fn pipeline_externals_state(&self) -> Option<&Arc<(AtomicU32, AtomicU32)>>

The pipeline externals state, for tracking the foreground process group, if present

source

fn get_config(&self) -> Result<Config, ShellError>

Get engine configuration

source

fn get_plugin_config(&self) -> Result<Option<Value>, ShellError>

Get plugin configuration

source

fn get_env_var(&self, name: &str) -> Result<Option<Value>, ShellError>

Get an environment variable from $env

source

fn get_env_vars(&self) -> Result<HashMap<String, Value>, ShellError>

Get all environment variables

source

fn get_current_dir(&self) -> Result<Spanned<String>, ShellError>

Get current working directory

source

fn add_env_var(&mut self, name: String, value: Value) -> Result<(), ShellError>

Set an environment variable

source

fn get_help(&self) -> Result<Spanned<String>, ShellError>

Get help for the current command

source

fn get_span_contents(&self, span: Span) -> Result<Spanned<Vec<u8>>, ShellError>

Get the contents of a Span

source

fn eval_closure( &self, closure: Spanned<Closure>, positional: Vec<Value>, input: PipelineData, redirect_stdout: bool, redirect_stderr: bool ) -> Result<PipelineData, ShellError>

Evaluate a closure passed to the plugin

source

fn boxed(&self) -> Box<dyn PluginExecutionContext>

Create an owned version of the context with 'static lifetime

Implementors§