Struct Flag

Source
pub struct Flag { /* private fields */ }
Expand description

Boolean arguments that can be toggled on or off.

Implementations§

Source§

impl Flag

Source

pub fn new() -> Self

Create a new instance.

Examples found in repository?
examples/main.rs (line 11)
5fn main() {
6  let msg = Manual::new("auth-service")
7    .about("authorize & authenticate members")
8    .arg(Arg::new("path"))
9    .env(Env::new("PORT").help("The network port to listen to"))
10    .flag(
11      Flag::new()
12        .short("-h")
13        .long("--help")
14        .help("Prints help information."),
15    )
16    .flag(
17      Flag::new()
18        .short("-V")
19        .long("--version")
20        .help("Prints version information."),
21    )
22    .flag(
23      Flag::new()
24        .short("-v")
25        .long("--verbosity")
26        .help("Pass multiple times to print more information."),
27    )
28    .option(
29      Opt::new("port")
30        .short("-p")
31        .long("--port")
32        .help("The network port to listen to."),
33    )
34    .example(
35      Example::new()
36        .text("listen on port 3000")
37        .command("auth-service -p 3000")
38        .output("now listening on port 3000"),
39    )
40    .example(
41      Example::new()
42        .text("auth-service may need to be run by root")
43        .prompt("#")
44        .command("auth-service"),
45    )
46    .custom(
47      Section::new("custom section")
48        .paragraph("text for the custom section")
49        .paragraph("Additional text for the custom section"),
50    )
51    .author(Author::new("Alice Person").email("alice@person.com"))
52    .author(Author::new("Bob Human").email("bob@human.com"))
53    .render();
54  // .option(Some("-o"), Some("--output"), "output", None, "Output file");
55
56  println!("{}", msg);
57}
Source

pub fn short(self, short: &str) -> Self

Set the short value.

Examples found in repository?
examples/main.rs (line 12)
5fn main() {
6  let msg = Manual::new("auth-service")
7    .about("authorize & authenticate members")
8    .arg(Arg::new("path"))
9    .env(Env::new("PORT").help("The network port to listen to"))
10    .flag(
11      Flag::new()
12        .short("-h")
13        .long("--help")
14        .help("Prints help information."),
15    )
16    .flag(
17      Flag::new()
18        .short("-V")
19        .long("--version")
20        .help("Prints version information."),
21    )
22    .flag(
23      Flag::new()
24        .short("-v")
25        .long("--verbosity")
26        .help("Pass multiple times to print more information."),
27    )
28    .option(
29      Opt::new("port")
30        .short("-p")
31        .long("--port")
32        .help("The network port to listen to."),
33    )
34    .example(
35      Example::new()
36        .text("listen on port 3000")
37        .command("auth-service -p 3000")
38        .output("now listening on port 3000"),
39    )
40    .example(
41      Example::new()
42        .text("auth-service may need to be run by root")
43        .prompt("#")
44        .command("auth-service"),
45    )
46    .custom(
47      Section::new("custom section")
48        .paragraph("text for the custom section")
49        .paragraph("Additional text for the custom section"),
50    )
51    .author(Author::new("Alice Person").email("alice@person.com"))
52    .author(Author::new("Bob Human").email("bob@human.com"))
53    .render();
54  // .option(Some("-o"), Some("--output"), "output", None, "Output file");
55
56  println!("{}", msg);
57}
Source

pub fn long(self, long: &str) -> Self

Set the long value.

Examples found in repository?
examples/main.rs (line 13)
5fn main() {
6  let msg = Manual::new("auth-service")
7    .about("authorize & authenticate members")
8    .arg(Arg::new("path"))
9    .env(Env::new("PORT").help("The network port to listen to"))
10    .flag(
11      Flag::new()
12        .short("-h")
13        .long("--help")
14        .help("Prints help information."),
15    )
16    .flag(
17      Flag::new()
18        .short("-V")
19        .long("--version")
20        .help("Prints version information."),
21    )
22    .flag(
23      Flag::new()
24        .short("-v")
25        .long("--verbosity")
26        .help("Pass multiple times to print more information."),
27    )
28    .option(
29      Opt::new("port")
30        .short("-p")
31        .long("--port")
32        .help("The network port to listen to."),
33    )
34    .example(
35      Example::new()
36        .text("listen on port 3000")
37        .command("auth-service -p 3000")
38        .output("now listening on port 3000"),
39    )
40    .example(
41      Example::new()
42        .text("auth-service may need to be run by root")
43        .prompt("#")
44        .command("auth-service"),
45    )
46    .custom(
47      Section::new("custom section")
48        .paragraph("text for the custom section")
49        .paragraph("Additional text for the custom section"),
50    )
51    .author(Author::new("Alice Person").email("alice@person.com"))
52    .author(Author::new("Bob Human").email("bob@human.com"))
53    .render();
54  // .option(Some("-o"), Some("--output"), "output", None, "Output file");
55
56  println!("{}", msg);
57}
Source

pub fn help(self, help: &str) -> Self

Set the help value.

Examples found in repository?
examples/main.rs (line 14)
5fn main() {
6  let msg = Manual::new("auth-service")
7    .about("authorize & authenticate members")
8    .arg(Arg::new("path"))
9    .env(Env::new("PORT").help("The network port to listen to"))
10    .flag(
11      Flag::new()
12        .short("-h")
13        .long("--help")
14        .help("Prints help information."),
15    )
16    .flag(
17      Flag::new()
18        .short("-V")
19        .long("--version")
20        .help("Prints version information."),
21    )
22    .flag(
23      Flag::new()
24        .short("-v")
25        .long("--verbosity")
26        .help("Pass multiple times to print more information."),
27    )
28    .option(
29      Opt::new("port")
30        .short("-p")
31        .long("--port")
32        .help("The network port to listen to."),
33    )
34    .example(
35      Example::new()
36        .text("listen on port 3000")
37        .command("auth-service -p 3000")
38        .output("now listening on port 3000"),
39    )
40    .example(
41      Example::new()
42        .text("auth-service may need to be run by root")
43        .prompt("#")
44        .command("auth-service"),
45    )
46    .custom(
47      Section::new("custom section")
48        .paragraph("text for the custom section")
49        .paragraph("Additional text for the custom section"),
50    )
51    .author(Author::new("Alice Person").email("alice@person.com"))
52    .author(Author::new("Bob Human").email("bob@human.com"))
53    .render();
54  // .option(Some("-o"), Some("--output"), "output", None, "Output file");
55
56  println!("{}", msg);
57}

Trait Implementations§

Source§

impl Clone for Flag

Source§

fn clone(&self) -> Flag

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Flag

Source§

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

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

impl Default for Flag

Source§

fn default() -> Flag

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Flag

§

impl RefUnwindSafe for Flag

§

impl Send for Flag

§

impl Sync for Flag

§

impl Unpin for Flag

§

impl UnwindSafe for Flag

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 = 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.