      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
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110

    macro_rules! remove_overriden {
        (@remove $_self:ident, $v:ident, $a:ident.$ov:ident) => {
            if let Some(ref ora) = $a.$ov {
                vec_remove_all!($_self.$v, ora);
            }
        };
        (@arg $_self:ident, $arg:ident) => {
            remove_overriden!(@remove $_self, required, $arg.requires);
            remove_overriden!(@remove $_self, blacklist, $arg.blacklist);
            remove_overriden!(@remove $_self, overrides, $arg.overrides);
        };
        ($_self:ident, $name:expr) => {
            debugln!("macro=remove_overriden!;");
            if let Some(ref o) = $_self.opts.iter().filter(|o| o.name == *$name).next() {
                remove_overriden!(@arg $_self, o);
            } else if let Some(ref f) = $_self.flags.iter().filter(|f| f.name == *$name).next() {
                remove_overriden!(@arg $_self, f);
            } else if let Some(p) = $_self.positionals.values().filter(|p| p.name == *$name).next() {
                remove_overriden!(@arg $_self, p);
            }
        };
    }

    macro_rules! arg_post_processing {
        ($me:ident, $arg:ident, $matcher:ident) => {
            debugln!("macro=arg_post_processing!;");
            // Handle POSIX overrides
            debug!("Is '{}' in overrides...", $arg.to_string());
            if $me.overrides.contains(&$arg.name()) {
                if let Some(ref name) = $me.overriden_from($arg.name(), $matcher) {
                    sdebugln!("Yes by {}", name);
                    $matcher.remove(name);
                    remove_overriden!($me, name);
                }
            } else { sdebugln!("No"); }

            // Add overrides
            debug!("Does '{}' have overrides...", $arg.to_string());
            if let Some(or) = $arg.overrides() {
                sdebugln!("Yes");
                $matcher.remove_all(or);
                for pa in or { remove_overriden!($me, pa); }
                $me.overrides.extend(or);
                vec_remove_all!($me.required, or);
            } else { sdebugln!("No"); }

            // Handle conflicts
            debug!("Does '{}' have conflicts...", $arg.to_string());
            if let Some(bl) = $arg.blacklist() {
                sdebugln!("Yes");
                $me.blacklist.extend(bl);
                vec_remove_all!($me.overrides, bl);
                vec_remove_all!($me.required, bl);
            } else { sdebugln!("No"); }

            // Add all required args which aren't already found in matcher to the master
            // list
            debug!("Does '{}' have requirements...", $arg.to_string());
            if let Some(reqs) = $arg.requires() {
                for n in reqs {
                    if $matcher.contains(&n) {
                        sdebugln!("\tYes '{}' but it's already met", n);
                        continue;
                    } else { sdebugln!("\tYes '{}'", n); }

                    $me.required.push(n);
                }
            } else { sdebugln!("No"); }

            _handle_group_reqs!($me, $arg);
        };
    }

    macro_rules! _handle_group_reqs{
        ($me:ident, $arg:ident) => ({
            use args::AnyArg;
            debugln!("macro=_handle_group_reqs!;");
            for grp in $me.groups.values() {
                let mut found = false;
                for name in &grp.args {
                    if name == &$arg.name() {
                        vec_remove!($me.required, name);
                        if let Some(ref reqs) = grp.requires {
                            $me.required.extend(reqs);
                        }
                        if let Some(ref bl) = grp.conflicts {
                            $me.blacklist.extend(bl);
                        }
                        found = true; // What if arg is in more than one group with different reqs?
                        break;
                    }
                }
                if found {
                    vec_remove_all!($me.required, &grp.args);
                    $me.blacklist.extend(&grp.args);
                    vec_remove!($me.blacklist, &$arg.name());
                }
            }
        })
    }

    macro_rules! validate_multiples {
        ($_self:ident, $a:ident, $m:ident) => {
            debugln!("macro=validate_multiples!;");
            if $m.contains(&$a.name) && !$a.settings.is_set(ArgSettings::Multiple) {
                // Not the first time, and we don't allow multiples
                return Err(Error::unexpected_multiple_usage($a, &*$_self.create_current_usage($m)))
            }
        };
    }

# 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`)