refactor
This commit is contained in:
parent
753f53d4da
commit
227b97b27f
6 changed files with 87 additions and 63 deletions
32
src/main.rs
32
src/main.rs
|
@ -97,20 +97,20 @@ pub fn read_conf(config_file: &str) -> InstallConfig {
|
|||
let config_content = std::fs::read_to_string(config_file);
|
||||
|
||||
match config_content {
|
||||
Ok(content) => match toml::from_str(&content) {
|
||||
Ok(config) => config,
|
||||
Err(e) => {
|
||||
eprintln!(
|
||||
"{} {}",
|
||||
"Error: Could not deserialize TOML file.".paint(Color::Red),
|
||||
e.paint(Color::Red)
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
eprintln!("{}", "Error: Could not read config file.".paint(Color::Red));
|
||||
std::process::exit(1);
|
||||
}
|
||||
Ok(content) => match toml::from_str(&content) {
|
||||
Ok(config) => config,
|
||||
Err(e) => {
|
||||
eprintln!(
|
||||
"{} {}",
|
||||
"Error: Could not deserialize TOML file.".paint(Color::Red),
|
||||
e.paint(Color::Red)
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
eprintln!("{}", "Error: Could not read config file.".paint(Color::Red));
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue