fix: exit with error code on failure (#1014)

add: print directories at start
This commit is contained in:
Zelda Hessler 2021-12-29 14:15:53 -06:00 committed by GitHub
parent b828dc80fe
commit 4fdb6bbe7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -59,20 +59,28 @@ pub(crate) use here;
/// --smithy-rs /Users/zhessler/Documents/smithy-rs-test/ \
/// --aws-sdk /Users/zhessler/Documents/aws-sdk-rust-test/
/// ```
fn main() {
fn main() -> Result<()> {
let Opt {
smithy_rs,
aws_sdk,
branch,
} = Opt::from_args();
if let Err(e) = sync_aws_sdk_with_smithy_rs(&smithy_rs, &aws_sdk, &branch) {
eprintln!("Sync failed with error: {:?}", e);
};
sync_aws_sdk_with_smithy_rs(&smithy_rs, &aws_sdk, &branch)
.map_err(|e| e.context("The sync failed"))
}
/// Run through all commits made to `smithy-rs` since last sync and "replay" them onto `aws-sdk-rust`.
fn sync_aws_sdk_with_smithy_rs(smithy_rs: &Path, aws_sdk: &Path, branch: &str) -> Result<()> {
eprintln!(
"aws-sdk-rust path:\t{}",
aws_sdk.canonicalize().context(here!())?.display()
);
eprintln!(
"smithy-rs path:\t{}",
smithy_rs.canonicalize().context(here!())?.display()
);
// Open the repositories we'll be working with
let smithy_rs_repo = Repository::open(smithy_rs).context("couldn't open smithy-rs repo")?;
let aws_sdk_repo = Repository::open(aws_sdk).context("couldn't open aws-sdk-rust repo")?;