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
use {
crate::*,
serde::Deserialize,
};
/// One of the possible job that bacon can run
#[derive(Debug, Clone, Deserialize)]
pub struct Job {
/// The tokens making the command to execute (first one
/// is the executable).
/// This vector is guaranteed not empty
/// by the PackageConfig::from_path loader
pub command: Vec<String>,
/// A list of directories that will be watched if the job
/// is run on a package.
/// src is implicitly included.
#[serde(default)]
pub watch: Vec<String>,
/// whether we need to capture stdout too (stderr is
/// always captured)
#[serde(default)]
pub need_stdout: bool,
/// the optional action to run when there's no
/// error, warning or test failures
#[serde(default)]
pub on_success: Option<Action>,
}
static DEFAULT_ARGS: &[&str] = &["--color", "always"];
impl Job {
/// Builds a `Job` for a cargo alias
pub fn from_alias(
alias_name: &str,
settings: &Settings,
) -> Self {
let mut command = vec!["cargo".to_string(), alias_name.to_string()];
if let Some(additional_args) = settings.additional_alias_args.as_ref() {
for arg in additional_args {
command.push(arg.to_string())
}
} else {
for arg in DEFAULT_ARGS {
command.push(arg.to_string())
}
}
Self {
command,
watch: Vec::new(),
need_stdout: false,
on_success: None,
}
}
}