Skip to main content

Command

Struct Command 

Source
pub struct Command {
    pub prog: &'static str,
    pub module: &'static str,
    pub help: &'static str,
    pub arguments: &'static [Argument],
    pub required_groups: &'static [usize],
}
Expand description

A command line declared with argparse: its prog, its module (for program_text), its help text as argparse prints it, and its arguments.

Fields§

§prog: &'static str

The prog of the parser, e.g. "fonttools ttLib.scaleUpem".

§module: &'static str

The module, without fontTools., e.g. "ttLib.scaleUpem".

§help: &'static str

parser.format_help(); its usage is the text before the first empty line.

§arguments: &'static [Argument]

The arguments.

§required_groups: &'static [usize]

The mutually exclusive groups with required=True.

Implementations§

Source§

impl Command

Source

pub fn usage(&self) -> &'static str

parser.format_usage().

Source

pub fn print_help(&self, out: &mut dyn Write) -> Result<()>

parser.print_help(): writes the help to out.

Source

pub fn error(&self, err: &mut dyn Write, message: &str) -> Result<i32>

parser.error(message): writes the usage and the message to err; returns the exit code, 2.

Source

pub fn parse_args( &self, args: &[&str], out: &mut dyn Write, err: &mut dyn Write, ) -> Result<Result<Parsed, i32>>

parser.parse_args(args): the parsed arguments, or the exit code when the help was printed to out (0) or an error to err (2).

Trait Implementations§

Source§

impl Clone for Command

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 Command

Source§

impl Debug for Command

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Command

§

impl Freeze for Command
where &'static str: Freeze, &'static [Argument]: Freeze, &'static [usize]: Freeze,

§

impl Move for Command

§

impl RefUnwindSafe for Command

§

impl Send for Command
where &'static str: Send, &'static [Argument]: Send, &'static [usize]: Send,

§

impl Sync for Command

§

impl Unpin for Command
where &'static str: Unpin, &'static [Argument]: Unpin, &'static [usize]: Unpin,

§

impl UnsafeUnpin for Command
where &'static str: UnsafeUnpin, &'static [Argument]: UnsafeUnpin, &'static [usize]: UnsafeUnpin,

§

impl UnwindSafe for Command
where &'static str: UnwindSafe, &'static [Argument]: UnwindSafe, &'static [usize]: UnwindSafe,

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.