Skip to main content

CommandInfo

Struct CommandInfo 

Source
#[non_exhaustive]
pub struct CommandInfo { pub name: &'static str, pub about: &'static str, pub long_about: &'static str, pub version: Option<&'static str>, pub args: &'static [ArgInfo], pub commands: &'static [CommandInfo], pub subcommand_required: bool, pub visible_aliases: &'static [&'static str], pub aliases: &'static [&'static str], pub hidden: bool, }
Expand description

The description of a command: its name, texts, arguments and subcommands.

Values are built with CommandInfo::new and the const builder methods, so that fields can be added without breaking existing code.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: &'static str

The name of the command, as typed on the command line.

§about: &'static str

The short description, from about or the first paragraph of the doc comment. Empty when not set.

§long_about: &'static str

The long description, from long_about or the full doc comment. Empty when not set.

§version: Option<&'static str>

The version set with #[command(version)].

§args: &'static [ArgInfo]

The arguments, flattened structs included, in field order, followed by the generated --help and --version flags.

§commands: &'static [CommandInfo]

The subcommands, from a #[command(subcommand)] field, in variant order. Their args do not repeat the global arguments of their parents.

§subcommand_required: bool

Whether one of the commands must be given.

§visible_aliases: &'static [&'static str]

The aliases of a subcommand listed in the help.

§aliases: &'static [&'static str]

The aliases of a subcommand hidden from the help.

§hidden: bool

Whether the subcommand is hidden from the help.

Implementations§

Source§

impl CommandInfo

Source

pub const fn new(name: &'static str) -> Self

A command named name, without description, version, arguments or subcommands.

Source

pub const fn subcommand_required(self, required: bool) -> Self

Source

pub const fn visible_aliases(self, aliases: &'static [&'static str]) -> Self

Source

pub const fn aliases(self, aliases: &'static [&'static str]) -> Self

Sets aliases.

Source

pub const fn hidden(self, hidden: bool) -> Self

Sets hidden.

Source

pub const fn about(self, about: &'static str) -> Self

Sets about.

Source

pub const fn long_about(self, long_about: &'static str) -> Self

Sets long_about.

Source

pub const fn version(self, version: &'static str) -> Self

Sets version.

Source

pub const fn args(self, args: &'static [ArgInfo]) -> Self

Sets args.

Source

pub const fn commands(self, commands: &'static [CommandInfo]) -> Self

Sets commands.

Trait Implementations§

Source§

impl Clone for CommandInfo

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CommandInfo

Source§

impl Debug for CommandInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CommandInfo

Source§

impl PartialEq for CommandInfo

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CommandInfo

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.