Support building directly from cookbook with --cookbook=

This commit is contained in:
Ian Douglas Scott
2017-04-09 10:11:49 -07:00
parent e2aa3c3032
commit bb94edcb15
2 changed files with 44 additions and 8 deletions
+14 -1
View File
@@ -7,13 +7,26 @@ extern crate toml;
use std::{env, process};
use std::fs::File;
use std::io::{self, Read, Write};
use std::path::Path;
fn main() {
let stderr = io::stderr();
let mut stderr = stderr.lock();
let mut configs = vec![];
let mut cookbook = None;
for arg in env::args().skip(1) {
if arg.starts_with("--cookbook=") {
let path = arg.splitn(2, "--cookbook=").nth(1).unwrap().to_string();
if !Path::new(&path).is_dir() {
writeln!(stderr, "installer: {}: cookbook not found", arg).unwrap();
process::exit(1);
}
cookbook = Some(path);
continue;
}
match File::open(&arg) {
Ok(mut config_file) => {
let mut config_data = String::new();
@@ -59,7 +72,7 @@ fn main() {
}
for config in configs {
if let Err(err) = redox_installer::install(config) {
if let Err(err) = redox_installer::install(config, cookbook.as_ref().map(String::as_ref)) {
writeln!(stderr, "installer: failed to install: {}", err).unwrap();
process::exit(1);
}