pub struct ConfigPlugin { /* private fields */ }Expand description
Standalone plugin providing config commands: show and validate.
Both handlers operate on the same CommandsConfig the application
attaches via with_config — there is no
separate config-loading logic here, only display and re-validation
of what the application already loaded.
§YAML config
commands:
- name: config-show
implementation: config_show
description: "Show the loaded configuration"
required: false
arguments: []
options: []
- name: config-validate
implementation: config_validate
description: "Re-validate the loaded configuration"
required: false
arguments: []
options: []§Example
use dynamic_cli::plugin::{ConfigPlugin, Plugin};
let plugin = ConfigPlugin::new();
assert_eq!(plugin.name(), "config");
let handlers = plugin.handlers();
assert_eq!(handlers.len(), 2);Implementations§
Source§impl ConfigPlugin
impl ConfigPlugin
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ConfigPlugin with no config attached.
§Example
use dynamic_cli::plugin::{ConfigPlugin, Plugin};
let plugin = ConfigPlugin::new();
assert_eq!(plugin.name(), "config");Sourcepub fn with_config(self, config: CommandsConfig) -> Self
pub fn with_config(self, config: CommandsConfig) -> Self
Attach the application’s config so config_show/config_validate
have something to operate on.
Call this yourself before
register_plugin —
CliBuilder::build() does not attach config to plugins on its own.
§Example
use dynamic_cli::plugin::{ConfigPlugin, Plugin};
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 plugin = ConfigPlugin::new().with_config(config);
assert_eq!(plugin.name(), "config");Trait Implementations§
Source§impl Default for ConfigPlugin
impl Default for ConfigPlugin
Source§impl Plugin for ConfigPlugin
impl Plugin for ConfigPlugin
Source§fn description(&self) -> &str
fn description(&self) -> &str
Human-readable description of what this plugin provides.
Auto Trait Implementations§
impl Freeze for ConfigPlugin
impl RefUnwindSafe for ConfigPlugin
impl Send for ConfigPlugin
impl Sync for ConfigPlugin
impl Unpin for ConfigPlugin
impl UnsafeUnpin for ConfigPlugin
impl UnwindSafe for ConfigPlugin
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