pub trait PluginCommand:
Send
+ Sync
+ 'static {
// Required methods
fn command(&self) -> Command;
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
matches: &'life1 ArgMatches,
) -> Pin<Box<dyn Future<Output = Result<(), CliError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn needs_ready(&self) -> bool { ... }
}Expand description
One CLI subcommand contributed by a plugin.
Required Methods§
Sourcefn command(&self) -> Command
fn command(&self) -> Command
The clap subcommand. Command::get_name() is the literal the
user types after the program name (umbral-cli <name>).
Long-form help, arg parsing, and subcommand grouping are all
the plugin’s to configure on the returned value.
Sourcefn run<'life0, 'life1, 'async_trait>(
&'life0 self,
matches: &'life1 ArgMatches,
) -> Pin<Box<dyn Future<Output = Result<(), CliError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
matches: &'life1 ArgMatches,
) -> Pin<Box<dyn Future<Output = Result<(), CliError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run the command. Called after clap has parsed args matching
self.command(); matches is the per-subcommand
ArgMatches (not the top-level one).
Provided Methods§
Sourcefn needs_ready(&self) -> bool
fn needs_ready(&self) -> bool
Whether this command needs a live application — pools open, schema
migrated, every plugin’s on_ready fired.
Default true, which is right for almost everything: a command that
touches data wants the app up.
Return false for a command that only touches the filesystem — a code
generator, a linter, a config dump. on_ready hooks seed content and
backfill rows, so firing them for startpermission means a pure
codegen command writes to the database, and on a fresh checkout it
fails against tables migrate has not created yet — before writing the
file it exists to write.
The framework’s own schema commands (migrate, makemigrations, …)
are excluded by name in umbral-cli; that list structurally cannot
know about a plugin’s offline commands, which is why the plugin gets to
declare it here.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".