CliHelpScreen

Struct CliHelpScreen 

Source
pub struct CliHelpScreen {
    pub title: String,
    pub usage: String,
    pub description: String,
    pub params: IndexMap<String, String>,
    pub flags: IndexMap<String, String>,
    pub examples: Vec<String>,
}
Expand description

Structure representing a help screen for a CLI command.

This struct contains all the information needed to render a complete help screen, including title, usage, description, parameters, flags, and examples.

Fields§

§title: String

The title displayed at the top of the help screen.

§usage: String

Usage string showing how to invoke the command.

§description: String

Detailed description of what the command does.

§params: IndexMap<String, String>

Map of parameter names to their descriptions.

§flags: IndexMap<String, String>

Map of flag names to their descriptions.

§examples: Vec<String>

List of example command invocations.

Implementations§

Source§

impl CliHelpScreen

Source

pub fn new(title: &str, usage: &str, description: &str) -> Self

Creates a new help screen with the specified title, usage, and description.

§Arguments
  • title - The title displayed at the top of the help screen
  • usage - Usage string showing how to invoke the command
  • description - Detailed description of what the command does
§Example
use falcon_cli::CliHelpScreen;

let help = CliHelpScreen::new(
    "My Command",
    "myapp command [OPTIONS]",
    "This command does something useful"
);
Source

pub fn add_param(&mut self, param: &str, description: &str)

Adds a parameter to the list displayed in the help screen.

§Arguments
  • param - The parameter name
  • description - Description of what the parameter does
§Example
let mut help = CliHelpScreen::new("Title", "usage", "desc");
help.add_param("filename", "The name of the file to process");
Source

pub fn add_flag(&mut self, flag: &str, description: &str)

Adds a flag to the list displayed in the help screen.

§Arguments
  • flag - The flag name (e.g., “–verbose” or “-v”)
  • description - Description of what the flag does
§Example
let mut help = CliHelpScreen::new("Title", "usage", "desc");
help.add_flag("--verbose|-v", "Enable verbose output");
Source

pub fn add_example(&mut self, example: &str)

Adds an example to the list displayed in the help screen.

§Arguments
  • example - An example command invocation
§Example
let mut help = CliHelpScreen::new("Title", "usage", "desc");
help.add_example("myapp command --verbose input.txt");
Source

pub fn render( cmd: &Box<dyn CliCommand>, cmd_alias: &String, shortcuts: &Vec<String>, )

Renders and displays the help screen for a specific CLI command.

This method is automatically executed when the first argument passed via the command line is ‘help’ or ‘-h’. It should not typically be called manually.

§Arguments
  • cmd - The CLI command to display help for
  • cmd_alias - The primary alias/name of the command
  • shortcuts - List of shortcut aliases for the command
Source

pub fn render_index(router: &CliRouter)

Renders and displays the main help index for the application.

This method is automatically executed when the first and only argument passed via the command line is ‘help’ or ‘-h’. It displays either all available categories or CLI commands depending on whether categories have been added to the router.

§Arguments
  • router - The CLI router containing all registered commands and categories
Source

pub fn render_category(router: &CliRouter, cat_alias: &String)

Renders and displays help for a specific category.

This method is only applicable when using multiple categories to organize groups of CLI commands. It is automatically executed when the first argument via command line is either ‘help’ or ‘-h’, and the second argument is the name of a category. It displays all CLI commands available within that category.

§Arguments
  • router - The CLI router containing all registered commands and categories
  • cat_alias - The alias/name of the category to display

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,