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
use cargo::core::compiler::CompileMode;
use clap::arg_enum;
use coveralls_api::CiService;
use std::str::FromStr;
use void::Void;
arg_enum! {
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
pub enum RunType {
Tests,
Doctests,
Benchmarks,
Examples,
}
}
arg_enum! {
#[derive(Debug)]
pub enum OutputFile {
Json,
Toml,
Stdout,
Xml,
Html,
Lcov,
}
}
impl Default for OutputFile {
#[inline]
fn default() -> Self {
OutputFile::Stdout
}
}
pub struct Ci(pub CiService);
impl From<RunType> for CompileMode {
fn from(run: RunType) -> Self {
match run {
RunType::Tests => CompileMode::Test,
RunType::Examples => CompileMode::Build,
RunType::Doctests => CompileMode::Doctest,
RunType::Benchmarks => CompileMode::Bench,
}
}
}
impl FromStr for Ci {
type Err = Void;
#[inline]
fn from_str(x: &str) -> Result<Ci, Self::Err> {
match x {
"circle-ci" => Ok(Ci(CiService::Circle)),
"codeship" => Ok(Ci(CiService::Codeship)),
"jenkins" => Ok(Ci(CiService::Jenkins)),
"semaphore" => Ok(Ci(CiService::Semaphore)),
"travis-ci" => Ok(Ci(CiService::Travis)),
"travis-pro" => Ok(Ci(CiService::TravisPro)),
other => Ok(Ci(CiService::Other(other.to_string()))),
}
}
}