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
use std::fmt;
use std::option::Option as Optional;
use std::string::String;
#[derive(Debug)]
pub struct Argument {
pub name: String,
pub help: String,
pub default_value: Optional<Vec<String>>,
}
impl Argument {
pub fn new(name: &str, help: &str, default_value: Optional<Vec<String>>) -> Argument {
Argument {
name: name.to_owned(),
help: help.to_owned(),
default_value: default_value,
}
}
}
impl fmt::Display for Argument {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "{} - {}", self.name, self.help));
if let Some(default) = self.default_value.as_ref() {
try!(write!(f, " [Default: {}]", &default[..].join(", ")));
}
Ok(())
}
}