tangled
alpha
login
or
join now
vielle.dev
/
tangled-on-commit
5
fork
atom
Listen to git commits for a specific repo and run a shell command
5
fork
atom
overview
issues
pulls
pipelines
Block out config loading
vielle.dev
6 months ago
55c93d2e
5ad7b51d
verified
This commit was signed with the committer's
known signature
.
vielle.dev
SSH Key Fingerprint:
SHA256:/4bvxqoEh9iMdjAPgcgAgXKZZQTROL3ULiPt6nH9RSs=
+35
1 changed file
expand all
collapse all
unified
split
src
main.rs
+35
src/main.rs
···
1
1
+
fn help() {
2
2
+
println!("tangled-on-commit")
3
3
+
}
4
4
+
5
5
+
#[derive(Debug)]
6
6
+
struct Config {
7
7
+
handle: String,
8
8
+
repo_name: String,
9
9
+
shell: String,
10
10
+
}
11
11
+
12
12
+
fn load_config() -> Result<Config, ()> {
13
13
+
// load config from cli args if present
14
14
+
// if omitted, fallback to a local `tangled-on-commit.json` file
15
15
+
// if key omitted or file not found, fall back to env
16
16
+
// if env omitted, error out and quit
17
17
+
18
18
+
return Ok(Config {
19
19
+
handle: String::from(""),
20
20
+
repo_name: String::from(""),
21
21
+
shell: String::from("")
22
22
+
});
23
23
+
}
24
24
+
1
25
fn main() -> Result<(), i32> {
26
26
+
2
27
// load configuration
28
28
+
let config = match load_config() {
29
29
+
Ok(res) => res,
30
30
+
Err(_) => {
31
31
+
// q
32
32
+
return Err(1)
33
33
+
}
34
34
+
};
35
35
+
36
36
+
help();
37
37
+
println!("{:#?}", config);
3
38
4
39
// resolve handle to did
5
40
// resolve did+repoName to knotserver