upstream_rs/application/features/
init.rs1use anyhow::{Result, anyhow};
2
3use crate::{
4 application::operations::init_operation::{check, cleanup, initialize},
5 utils::static_paths::UpstreamPaths,
6};
7
8pub fn run(cleanup_option: bool, check_option: bool) -> Result<()> {
9 let paths = UpstreamPaths::new();
10
11 if check_option {
12 let report = check(&paths)?;
13 for line in &report.messages {
14 println!("{}", line);
15 }
16
17 if report.ok {
18 println!("Initialization check passed.");
19 return Ok(());
20 }
21
22 return Err(anyhow!("Initialization check failed"));
23 }
24
25 if cleanup_option {
26 cleanup(&paths)?;
27 println!("Cleared upstream data.")
28 } else {
29 initialize(&paths)?;
30 println!("Initialized upstream.")
31 }
32
33 Ok(())
34}