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