pub struct SubcommandRunner { /* private fields */ }
Expand description
A struct that manages loading and running subcommand plugins
Implementations§
Source§impl SubcommandRunner
impl SubcommandRunner
Sourcepub async fn new_with_plugins(
plugins: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Result<Self>
pub async fn new_with_plugins( plugins: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Result<Self>
Create a new runner initialized with the list of plugins provided.
This function will fail if any of the plugins fail to load. If you want to gracefully handle
errors, use add_plugin
instead.
Sourcepub async fn add_plugin(&mut self, path: impl AsRef<Path>) -> Result<Metadata>
pub async fn add_plugin(&mut self, path: impl AsRef<Path>) -> Result<Metadata>
Adds a plugin to the runner, returning the metadata for the plugin and otherwise returning an error if there was a problem loading the plugin. This can happen due to bad instantiation or if a plugin with the same ID has already been loaded. As such, errors from this function should be treated as a warning as execution can continue
Sourcepub async fn update_plugin(
&mut self,
path: impl AsRef<Path>,
) -> Result<Metadata>
pub async fn update_plugin( &mut self, path: impl AsRef<Path>, ) -> Result<Metadata>
Same as add_plugin
, but will not return an error if the plugin exists,
instead updating the metadata for the plugin. This is an upsert operation and will register
the plugin if it does not exist.
Sourcepub fn metadata(&self, id: &str) -> Option<&Metadata>
pub fn metadata(&self, id: &str) -> Option<&Metadata>
Get the metadata for a plugin with the given ID if it exists.
Sourcepub fn all_metadata(&self) -> Vec<&Metadata>
pub fn all_metadata(&self) -> Vec<&Metadata>
Returns a list of all metadata for all plugins.
Sourcepub fn path(&self, id: &str) -> Option<&Path>
pub fn path(&self, id: &str) -> Option<&Path>
Returns the path to the plugin with the given ID.
Sourcepub async fn run(
&mut self,
plugin_id: &str,
plugin_dir: PathBuf,
dirs: Vec<DirMapping>,
args: Vec<String>,
) -> Result<()>
pub async fn run( &mut self, plugin_id: &str, plugin_dir: PathBuf, dirs: Vec<DirMapping>, args: Vec<String>, ) -> Result<()>
Run a subcommand with the given name and args. The plugin will inherit all
stdout/stderr/stdin/env. The given plugin_dirs will be mapped into the plugin after
canonicalizing all paths and normalizing them to use /
instead of \
. An error will only
be returned if there was a problem with the plugin (such as the plugin dirs not existing or
failure to canonicalize) or the subcommand itself.
All plugins will be passed environment variables starting with
WASH_PLUGIN_${plugin_id.to_upper()}_
from the current process. Other vars will be ignored
Auto Trait Implementations§
impl Freeze for SubcommandRunner
impl !RefUnwindSafe for SubcommandRunner
impl Send for SubcommandRunner
impl !Sync for SubcommandRunner
impl Unpin for SubcommandRunner
impl !UnwindSafe for SubcommandRunner
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self
file descriptor. Read moreSource§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more