     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81

    use std::str::FromStr;
    use std::ascii::AsciiExt;

    bitflags! {
        flags Flags: u8 {
            const REQUIRED   = 0b00001,
            const MULTIPLE   = 0b00010,
            const EMPTY_VALS = 0b00100,
            const GLOBAL     = 0b01000,
            const HIDDEN     = 0b10000,
        }
    }

    #[derive(Debug)]
    pub struct ArgFlags(Flags);

    impl ArgFlags {
        pub fn new() -> Self {
            ArgFlags(EMPTY_VALS)
        }

        pub fn set(&mut self, s: &ArgSettings) {
            match *s {
                ArgSettings::Required => self.0.insert(REQUIRED),
                ArgSettings::Multiple => self.0.insert(MULTIPLE),
                ArgSettings::EmptyValues => self.0.insert(EMPTY_VALS),
                ArgSettings::Global => self.0.insert(GLOBAL),
                ArgSettings::Hidden => self.0.insert(HIDDEN),
            }
        }

        pub fn unset(&mut self, s: &ArgSettings) {
            match *s {
                ArgSettings::Required => self.0.remove(REQUIRED),
                ArgSettings::Multiple => self.0.remove(MULTIPLE),
                ArgSettings::EmptyValues => self.0.remove(EMPTY_VALS),
                ArgSettings::Global => self.0.remove(GLOBAL),
                ArgSettings::Hidden => self.0.remove(HIDDEN),
            }
        }

        pub fn is_set(&self, s: &ArgSettings) -> bool {
            match *s {
                ArgSettings::Required => self.0.contains(REQUIRED),
                ArgSettings::Multiple => self.0.contains(MULTIPLE),
                ArgSettings::EmptyValues => self.0.contains(EMPTY_VALS),
                ArgSettings::Global => self.0.contains(GLOBAL),
                ArgSettings::Hidden => self.0.contains(HIDDEN),
            }
        }
    }

    impl Default for ArgFlags {
        fn default() -> Self {
            ArgFlags::new()
        }
    }

    #[doc(hidden)]
    #[derive(Debug, PartialEq)]
    pub enum ArgSettings {
        Required,
        Multiple,
        EmptyValues,
        Global,
        Hidden,
    }

    impl FromStr for ArgSettings {
        type Err = String;
        fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err> {
            match &*s.to_ascii_lowercase() {
                "required" => Ok(ArgSettings::Required),
                "multiple" => Ok(ArgSettings::Multiple),
                "global" => Ok(ArgSettings::Global),
                "emptyvalues" => Ok(ArgSettings::EmptyValues),
                "hidden" => Ok(ArgSettings::Hidden),
                _ => Err("unknown ArgSetting, cannot convert from str".to_owned()),
            }
        }
    }

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)