diff --git a/README.md b/README.md index 05613ed..c6068c9 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ FLAGS: OPTIONS: -o, --output Path to the output file -t, --template Path to the template file - -v, --variables Path to the JSON file + -v, --variables Path to the JSON file ``` diff --git a/src/main.rs b/src/main.rs index 204e557..e876f64 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,8 +16,7 @@ struct KeyValuePairs(BTreeMap); struct Config { template_file: String, output_file: String, - json_file: String, - yaml_file: String, + variables_file: String, } fn main() -> Result<(), Box> { @@ -27,14 +26,14 @@ fn main() -> Result<(), Box> { // initialize KeyValuePair type let key_value_pairs: KeyValuePairs; - if config.json_file.is_empty() { + if config.variables_file.is_empty() { // Process the JSON value trough stdin let mut input = String::new(); io::stdin().read_to_string(&mut input)?; key_value_pairs = serde_json::from_str(&input)?; } else { // Read JSON file - let json_content = fs::read_to_string(config.json_file)?; + let json_content = fs::read_to_string(config.variables_file)?; key_value_pairs = serde_json::from_str(&json_content)?; } @@ -78,28 +77,19 @@ fn get_args() -> Result> { .help("Path to the output file"), ) .arg( - Arg::with_name("variables_json") - .short("j") - .long("variables-json") + Arg::with_name("variables_file") + .short("v") + .long("variables") .required(false) .takes_value(true) .help("Path to the JSON file"), ) - .arg( - Arg::with_name("variables_yaml") - .short("y") - .long("variables-yaml") - .required(false) - .takes_value(true) - .help("Path to the YAML file"), - ) .get_matches(); Ok(Config { template_file: matches.value_of("template_file").unwrap().to_string(), output_file: matches.value_of("output_file").unwrap_or("").to_string(), - json_file: matches.value_of("variables_json").unwrap_or("").to_string(), - yaml_file: matches.value_of("variables_yaml").unwrap_or("").to_string(), + variables_file: matches.value_of("variables_file").unwrap_or("").to_string(), }) } @@ -125,6 +115,11 @@ fn manifest_writer(output: &String, template: &String) -> Result<(), Box Result<(), Box> { +// +// Ok(()) +//} + // -------------------------------------------------- fn print_current_dir() { if let Ok(current_dir) = env::current_dir() {