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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#![crate_name = "reef"]
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::marker::Sized;
use std::path::{Path, PathBuf};
use std::time::Duration;
#[macro_use]
extern crate error_chain;
pub mod errors;
pub use errors::*;
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Env {
username: String,
hostname: String,
distro: String,
realname: String,
devicename: String,
}
mod env;
pub struct Paths;
mod paths;
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct Command {
dir: PathBuf,
name: String,
args: Vec<String>,
stdout: String,
stderr: String,
success: bool,
exit_code: i32,
duration: Duration,
start: String,
env: Env,
tags: HashSet<String>,
uuid: String,
}
mod command;
#[derive(Serialize, Deserialize)]
pub struct Remotes {
origins: HashSet<String>,
#[serde(skip_serializing)]
filename: PathBuf,
}
pub mod remotes;
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct Commit {
origin: String,
name: String,
branch: String,
author: String,
message: String,
date: String,
size: i64,
}
pub struct Git;
mod git;
pub struct Runner;
mod runner;
#[derive(Debug)]
pub enum Tasks {
Clobber,
Build,
Test,
Default,
}
mod string;
pub trait Format {
fn to_bytes<T: Sized + Serialize>(value: T) -> errors::Result<Vec<u8>>;
fn from_bytes<T: DeserializeOwned>(bytes: Vec<u8>) -> errors::Result<T>;
fn save_as<T: Sized + Serialize>(value: T, path: &Path) -> errors::Result<()> {
match Self::to_bytes(&value) {
Ok(bytes) => match std::fs::write(path, &bytes) {
Ok(_) => Ok(()),
Err(e) => Err(errors::Error::from(e)),
},
Err(e) => Err(errors::Error::from(e)),
}
}
fn open<T: DeserializeOwned>(path: &Path) -> errors::Result<T> {
match std::fs::read(path) {
Ok(bytes) => match serde_json::from_slice::<T>(&bytes) {
Ok(value) => Ok(value),
Err(e) => Err(errors::Error::from(e)),
},
Err(e) => Err(errors::Error::from(e)),
}
}
}
pub mod format;