pub struct VersionPlugin { /* private fields */ }Expand description
Standalone builtin providing only the version command.
Use this instead of [SystemPlugin][crate::builtin::system::SystemPlugin]
when an application wants version without also registering help and
exit.
§YAML config
commands:
- name: version
implementation: system_version
description: "Show version"
required: false
arguments: []
options: []§Example
use dynamic_cli::plugin::{Plugin, VersionPlugin};
let builtin = VersionPlugin::new();
assert_eq!(builtin.name(), "version");
let handlers = builtin.handlers();
assert_eq!(handlers.len(), 1);
assert_eq!(handlers[0].0, "system_version");Implementations§
Source§impl VersionPlugin
impl VersionPlugin
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new VersionPlugin with no config attached.
§Example
use dynamic_cli::plugin::{Plugin, VersionPlugin};
let builtin = VersionPlugin::new();
assert_eq!(builtin.name(), "version");Sourcepub fn with_config(self, config: CommandsConfig) -> Self
pub fn with_config(self, config: CommandsConfig) -> Self
Attach a config so the handler can read metadata.version.
Call this yourself before
register_plugin —
CliBuilder::build() does not attach config to plugins on its own.
§Example
use dynamic_cli::plugin::{Plugin, VersionPlugin};
use dynamic_cli::config::schema::{CommandsConfig, Metadata};
let config = CommandsConfig {
metadata: Metadata {
version: "1.0.0".to_string(),
prompt: "myapp".to_string(),
prompt_suffix: " > ".to_string(),
},
commands: vec![],
global_options: vec![],
};
let builtin = VersionPlugin::new().with_config(config);
assert_eq!(builtin.name(), "version");Trait Implementations§
Source§impl Default for VersionPlugin
impl Default for VersionPlugin
Source§impl Plugin for VersionPlugin
impl Plugin for VersionPlugin
Source§fn description(&self) -> &str
fn description(&self) -> &str
Human-readable description of what this plugin provides.
Auto Trait Implementations§
impl Freeze for VersionPlugin
impl RefUnwindSafe for VersionPlugin
impl Send for VersionPlugin
impl Sync for VersionPlugin
impl Unpin for VersionPlugin
impl UnsafeUnpin for VersionPlugin
impl UnwindSafe for VersionPlugin
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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