Struct parg::Arg[][src]

pub struct Arg { /* fields omitted */ }
Expand description

This structure represents an Argument for the command line in the form “–arg_name value”.

Implementations

Get the name of the Arg.

Example

// match the optional i32 argument --foo <value>
let arg = Arg::with_value("foo", Type::ReadAsI32, false);
assert_eq!(arg.get_name(), String::from("foo"));

Sets the Arg description.

Arguments

  • description - The description of the argument.

Example

let a = Arg::with_value("config", Type::ReadAsString, true);
a.set_description("The argument description");

Construct an Arg expecting a value and having a default one.

Arguments

  • name - The name of the argument.
  • reading_type - The expected Type of the argument.
  • default_value - The default value of the argument.
  • required - Check if whether or not the argument is required.

Example

// match the optional i32 argument --foo <value>
let arg = Arg::with_default_value("foo", Type::ReadAsI32, Box::new(42i32), false);

Construct an Arg expecting a value.

Arguments

  • name - The name of the argument.
  • reading_type - The expected Type of the argument.
  • required - Check if whether or not the argument is required.

Example

// match the optional i32 argument --foo <value>
let arg = Arg::with_value("foo", Type::ReadAsI32, false);

Construct an Arg expecting no value.

Arguments

  • name - The name of the argument.
  • required - Check if whether or not the argument is required.

Example

// match the optional argument --foo
let arg = Arg::without_value("foo", false);

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.