-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reinstated save_ref command, accepted prog gen signature change
- Loading branch information
Showing
8 changed files
with
373 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,67 @@ | ||
use origen_metal::framework::reference_files; | ||
use std::path::Path; | ||
|
||
pub fn run(matches: &clap::ArgMatches) { | ||
let mut exit_code = 0; | ||
use origen_metal::framework::reference_files; | ||
use crate::commands::_prelude::*; | ||
|
||
pub const BASE_CMD: &'static str = "save_ref"; | ||
|
||
gen_core_cmd_funcs!( | ||
BASE_CMD, | ||
"Save a reference version of the given file, this will be automatically checked for differences the next time it is generated", | ||
{ |cmd: App<'a>| { | ||
cmd | ||
.arg( | ||
Arg::new("files") | ||
.help("The name of the file(s) to be saved") | ||
.action(SetArg) | ||
.value_name("FILES") | ||
.multiple(true) | ||
.required_unless_one(&["new", "changed"]), | ||
) | ||
.arg( | ||
Arg::new("new") | ||
.long("new") | ||
.required(false) | ||
.action(SetArgTrue) | ||
.help("Update all NEW file references from the last generate run"), | ||
) | ||
.arg( | ||
Arg::new("changed") | ||
.long("changed") | ||
.required(false) | ||
.action(SetArgTrue) | ||
.help("Update all CHANGED file references from the last generate run"), | ||
) | ||
}} | ||
); | ||
|
||
|
||
pub fn run(matches: &clap::ArgMatches) -> Result<()> { | ||
let new = matches.contains_id("new"); | ||
let changed = matches.contains_id("changed"); | ||
let files = matches.get_many::<String>("files"); | ||
|
||
if new { | ||
if let Err(e) = reference_files::apply_all_new_refs() { | ||
log_error!("Something went wrong saving the NEW references - {}", e); | ||
exit_code = 1; | ||
bail!("Something went wrong saving the NEW references - {}", e); | ||
} | ||
} | ||
|
||
if changed { | ||
if let Err(e) = reference_files::apply_all_changed_refs() { | ||
log_error!( | ||
bail!( | ||
"Something went wrong updating the CHANGED references - {}", | ||
e | ||
); | ||
exit_code = 1; | ||
} | ||
} | ||
|
||
if let Some(files) = files { | ||
for key in files { | ||
if let Err(e) = reference_files::apply_ref(Path::new(key)) { | ||
log_error!("Could not save '{}' - {}", key, e); | ||
exit_code = 1; | ||
bail!("Could not save '{}' - {}", key, e); | ||
} | ||
} | ||
} | ||
std::process::exit(exit_code); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.