Skip to content

Commit b75b3d6

Browse files
committed
Fix result handling in init command runner
Signed-off-by: Robert Detjens <github@detjens.dev>
1 parent cb36287 commit b75b3d6

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

src/commands/init.rs

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,31 @@
1-
use simplelog::error;
1+
use anyhow::Result;
22
use std::fs::File;
33
use std::io::Write;
44
use std::process::exit;
5+
use tracing::error;
56

67
use crate::init::{self as init, templatize_init};
78
use crate::{access_handlers::frontend, commands::deploy};
89

9-
pub fn run(_interactive: &bool, _blank: &bool) {
10+
pub fn run(_interactive: &bool, _blank: &bool) -> Result<()> {
1011
let options: init::InitVars;
1112

1213
if *_interactive {
13-
options = match init::interactive_init() {
14-
Ok(t) => t,
15-
Err(e) => {
16-
error!("Error in init: {e}");
17-
exit(1);
18-
}
19-
};
14+
options = init::interactive_init()?;
2015
} else if *_blank {
2116
options = init::blank_init();
2217
} else {
2318
options = init::example_init();
2419
}
2520

2621
let configuration = templatize_init(options);
27-
let mut f = match File::create("rcds.yaml") {
28-
Ok(t) => t,
29-
Err(e) => {
30-
error!("Error in init: {e}");
31-
exit(1);
32-
}
33-
};
34-
match f.write_all(configuration.as_bytes()) {
35-
Ok(_) => (),
36-
Err(e) => {
37-
error!("Error in init: {e}");
38-
exit(1);
39-
}
40-
}
22+
23+
let mut f = File::create("rcds.yaml")?;
24+
f.write_all(configuration.as_bytes())?;
4125

4226
// Note about external-dns
4327
println!("Note: external-dns configuration settings will need to be provided in rcds.yaml after file creation, under the `profiles.name.dns` key.");
4428
println!("Reference: https://github.com/bitnami/charts/tree/main/bitnami/external-dns");
29+
30+
Ok(())
4531
}

0 commit comments

Comments
 (0)