This commit is contained in:
parent
59203d9085
commit
753f53d4da
5 changed files with 27 additions and 42 deletions
62
src/main.rs
62
src/main.rs
|
@ -50,25 +50,7 @@ fn main() {
|
|||
}
|
||||
Some(("create-img", install_args)) => {
|
||||
let config_file: &String = install_args.get_one("config").unwrap();
|
||||
let config_content = std::fs::read_to_string(config_file);
|
||||
|
||||
let conf: InstallConfig = 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);
|
||||
}
|
||||
};
|
||||
let conf = read_conf(config_file);
|
||||
|
||||
println!("Installing to a disk image is not yet supported");
|
||||
unimplemented!()
|
||||
|
@ -81,25 +63,7 @@ fn main() {
|
|||
|
||||
let config_file: &String = install_args.get_one("config").unwrap();
|
||||
let force = install_args.get_flag("force");
|
||||
let config_content = std::fs::read_to_string(config_file);
|
||||
|
||||
let conf: InstallConfig = 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);
|
||||
}
|
||||
};
|
||||
let conf = read_conf(config_file);
|
||||
|
||||
if !force {
|
||||
print_config(&conf);
|
||||
|
@ -128,3 +92,25 @@ pub fn expect_yes() {
|
|||
std::process::exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue