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
pub mod when;
pub use when::*;
use super::{Param, SyntaxHighLight};
use structopt::*;
#[derive(StructOpt)]
#[structopt(name = "pretty-exec", rename_all = "kebab")]
pub struct Args {
#[structopt(name = "program")]
program: String,
#[structopt(name = "arguments")]
arguments: Vec<String>,
#[structopt(long)]
skip_exec: bool,
#[structopt(long, default_value = "auto", possible_values = &["auto", "never", "always"])]
color: When,
#[structopt(long)]
github_actions: bool,
}
impl Args {
pub fn syntax_highlight(&self) -> SyntaxHighLight<String> {
if self.color == When::Never {
SyntaxHighLight::default_colorless()
} else {
SyntaxHighLight::default_color()
}
}
pub fn param(&'_ self) -> Param<'_> {
Param {
program: self.program.as_str(),
arguments: self.arguments.as_ref(),
skip_exec: self.skip_exec,
support_github_action: self.github_actions,
syntax_highlight: self.syntax_highlight(),
}
}
}