Skip to content

Commit

Permalink
Add --json flag to output json
Browse files Browse the repository at this point in the history
  • Loading branch information
sveitser committed Sep 22, 2023
1 parent 71c6333 commit 5dfc018
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions zkevm-contract-bindings/src/bin/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,15 @@ pub struct Options {
#[arg(
short,
long,
env = "ESPRESSO_ZKEVM_DEPLOY_OUTPUT",
env = "ESPRESSO_ZKEVM_DEPLOY_OUTPUT_PATH",
default_value = "deployment.env"
)]
pub output_path: PathBuf,

/// Output file path where deployment info will be stored.
#[arg(long, env = "ESPRESSO_ZKEVM_DEPLOY_OUTPUT_JSON")]
pub json: bool,

/// Polling interval for the RPC provider
///
/// By default the ether-rs default of 7 seconds will be used.
Expand Down Expand Up @@ -430,8 +434,13 @@ async fn deploy(opts: Options) -> Result<()> {
zkevm_2_output,
};

std::fs::write(&opts.output_path, output.to_dotenv())?;
let content = if opts.json {
serde_json::to_string_pretty(&output)?
} else {
output.to_dotenv()
};
tracing::info!("Wrote deployment output to {}", opts.output_path.display());
std::fs::write(&opts.output_path, content)?;

Ok(())
}
Expand Down

0 comments on commit 5dfc018

Please sign in to comment.