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
use clap_flags;
use failure::ResultExt;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
pub struct Cli {
#[structopt(flatten)]
logger: clap_flags::Log,
#[structopt(default_value = ".")]
path: String,
#[structopt(short = "o", long = "out")]
file: Option<String>,
}
impl Cli {
#[inline]
pub fn log(&self, name: &str) -> crate::Result<()> {
self
.logger
.start(name)
.map_err(failure::Error::from_boxed_compat)
.context(crate::ErrorKind::Log)?;
Ok(())
}
#[inline]
pub fn path(&self) -> &str {
&self.path
}
#[inline]
pub fn file(&self) -> &Option<String> {
&self.file
}
}