1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::path::Path;

pub fn run(matches: &clap::ArgMatches) {
    let mut exit_code = 0;

    let new = matches.is_present("new");
    let changed = matches.is_present("changed");
    let files = matches.values_of("files");

    if new {
        if let Err(e) = origen::core::reference_files::apply_all_new_refs() {
            log_error!("Something went wrong saving the NEW references - {}", e);
            exit_code = 1;
        }
    }

    if changed {
        if let Err(e) = origen::core::reference_files::apply_all_changed_refs() {
            log_error!(
                "Something went wrong updating the CHANGED references - {}",
                e
            );
            exit_code = 1;
        }
    }

    if let Some(files) = files {
        for key in files {
            if let Err(e) = origen::core::reference_files::apply_ref(Path::new(key)) {
                log_error!("Could not save '{}' - {}", key, e);
                exit_code = 1;
            }
        }
    }
    std::process::exit(exit_code);
}