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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#![warn(warnings)]
#![forbid(missing_debug_implementations, unconditional_recursion, future_incompatible)]
#![deny(bad_style, missing_docs, unsafe_code, unused)]
#![warn(unreachable_pub)]
#![cfg_attr(feature = "nightly", feature(non_exhaustive))]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "nightly", non_exhaustive)]
pub enum CI {
Jenkins(Jenkins),
Travis(Travis),
Docker(Docker),
Codeship(Codeship),
Codefresh(Codefresh),
Circle(Circle),
Appveyor(Appveyor),
#[doc(hidden)] __NonExhaustive,
}
impl CI {
#[cfg_attr(rustfmt, rustfmt_skip)]
pub fn from_env() -> Option<Self> {
None
.or_else(|| Jenkins ::from_env().map(CI::Jenkins ))
.or_else(|| Travis ::from_env().map(CI::Travis ))
.or_else(|| Docker ::from_env().map(CI::Docker ))
.or_else(|| Codeship ::from_env().map(CI::Codeship ))
.or_else(|| Codefresh::from_env().map(CI::Codefresh))
.or_else(|| Circle ::from_env().map(CI::Circle ))
.or_else(|| Appveyor ::from_env().map(CI::Appveyor ))
}
}
fn env(var: &str) -> Option<String> {
let env_var = std::env::var(var).unwrap_or_default();
if !env_var.is_empty() {
Some(env_var)
} else {
None
}
}
pub mod jenkins;
pub use jenkins::Jenkins;
pub mod travis;
pub use travis::Travis;
pub mod docker;
pub use docker::Docker;
pub mod codeship;
pub use codeship::Codeship;
pub mod codefresh;
pub use codefresh::Codefresh;
pub mod circle;
pub use circle::Circle;
pub mod appveyor;
pub use appveyor::Appveyor;