claptrap 0.3.0

Bring the power of Clap to shell scripts.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/// Extension trait for `clap::Arg` to determine if it is many-valued.
pub trait IsManyEx {
    /// Returns true if the argument is many-valued.
    fn is_many(&self) -> bool;
}

impl IsManyEx for clap::Arg {
    fn is_many(&self) -> bool {
        self.get_num_args()
            .map(|r| r.max_values() > 1)
            .or_else(|| self.get_value_delimiter().map(|_| true))
            .unwrap_or(false)
    }
}