pub struct HelpView { /* private fields */ }Expand description
A renderable help page for a CommandSpec.
use rich::Console;
use rich_ext::cli_doc::{ArgSpec, CommandSpec, HelpView};
let spec = CommandSpec::new("tool")
.arg(ArgSpec::option("level").choices(["low", "high"]).default_value("low").help("How much"));
let out = Console::builder().width(80).build().render_to_string(&HelpView::new(&spec));
assert!(out.contains("--level <LEVEL> How much [default: low] [possible values: low, high]"));Implementations§
Source§impl HelpView
impl HelpView
pub fn new(spec: &CommandSpec) -> Self
Sourcepub fn for_path(root: &CommandSpec, path: &[&str]) -> Option<Self>
pub fn for_path(root: &CommandSpec, path: &[&str]) -> Option<Self>
The help for the subcommand at path below root (such as
["config", "show"]), with the full command path in its usage.
Sourcepub fn long(self, long: bool) -> Self
pub fn long(self, long: bool) -> Self
Long help (--help): long about and long argument help where given,
and a blank line between entries.
Sourcepub fn command_path(self, path: impl Into<String>) -> Self
pub fn command_path(self, path: impl Into<String>) -> Self
The command as usage shows it, such as rich config.
Trait Implementations§
Source§impl Renderable for HelpView
impl Renderable for HelpView
fn rich_render(&self, c: &Console, o: &ConsoleOptions) -> Vec<Segment>
Source§fn measure(&self, c: &Console, o: &ConsoleOptions) -> Measurement
fn measure(&self, c: &Console, o: &ConsoleOptions) -> Measurement
The
(minimum, maximum) cell width this renderable wants. The default
assumes the renderable fills the available width (e.g. Panel, Table);
Text overrides it with its content width so the top-level print path can
shrink to fit. Port of __rich_measure__ / Measurement.get.Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
Whether a top-level
Console::print shrinks this renderable to its
measured width. Upstream renders every top-level renderable at the full
console width, so the default is false; an extension may opt in.Auto Trait Implementations§
impl Freeze for HelpView
impl RefUnwindSafe for HelpView
impl Send for HelpView
impl Sync for HelpView
impl Unpin for HelpView
impl UnsafeUnpin for HelpView
impl UnwindSafe for HelpView
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