-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: not all commands need the same params * feat: versions command
- Loading branch information
Showing
6 changed files
with
125 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use std::env; | ||
|
||
const CDK_CLIENT_BIN: &str = "cdk-node"; | ||
|
||
pub(crate) fn get_bin_path() -> String { | ||
// This is to find the binary when running in development mode | ||
// otherwise it will use system path | ||
let mut bin_path = env::var("CARGO_MANIFEST_DIR").unwrap_or(CDK_CLIENT_BIN.into()); | ||
if bin_path != CDK_CLIENT_BIN { | ||
bin_path = format!("{}/../../target/{}", bin_path, CDK_CLIENT_BIN); | ||
} | ||
bin_path | ||
} |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use colored::*; | ||
use execute::Execute; | ||
use std::io; | ||
use std::process::{Command, Output}; | ||
|
||
fn version() -> Result<Output, io::Error> { | ||
let bin_path = crate::helpers::get_bin_path(); | ||
|
||
// Run the node passing the config file path as argument | ||
let mut command = Command::new(bin_path.clone()); | ||
command.args(&["version"]); | ||
|
||
command.execute_output() | ||
} | ||
|
||
pub(crate) fn versions() { | ||
// Get the version of the cdk-node binary. | ||
let output = version().unwrap(); | ||
let version = String::from_utf8(output.stdout).unwrap(); | ||
|
||
println!("{}", format!("{}", version.trim()).green()); | ||
|
||
let versions = vec![ | ||
( | ||
"zkEVM Contracts", | ||
"https://github.com/0xPolygonHermez/zkevm-contracts/releases/tag/v8.0.0-rc.4-fork.12", | ||
), | ||
("zkEVM Prover", "v8.0.0-RC12"), | ||
("CDK Erigon", "hermeznetwork/cdk-erigon:0948e33"), | ||
( | ||
"zkEVM Pool Manager", | ||
"hermeznetwork/zkevm-pool-manager:v0.1.1", | ||
), | ||
( | ||
"CDK Data Availability Node", | ||
"0xpolygon/cdk-data-availability:0.0.10", | ||
), | ||
]; | ||
|
||
// Multi-line string to print the versions with colors. | ||
let formatted_versions: Vec<String> = versions | ||
.iter() | ||
.map(|(key, value)| format!("{}: {}", key.green(), value.blue())) | ||
.collect(); | ||
|
||
println!("{}", formatted_versions.join("\n")); | ||
} |