-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update template CLI for latest changes to CLI
- Loading branch information
Showing
1 changed file
with
34 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,50 @@ | ||
use colored::Colorize; | ||
use entropy_test_cli::{run_command, PROGRAM_VERSION_NUMBER}; | ||
use dotenv::dotenv; | ||
use entropy_test_cli::{run_command, PROGRAM_VERSION_NUMBER}; | ||
use generate_types::generate_types; | ||
use project_root::get_project_root; | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
dotenv().ok(); | ||
let program = format!("{}/target/wasm32-unknown-unknown/release/{{project-name}}.wasm", get_project_root()?.to_string_lossy()); | ||
let program = format!( | ||
"{}/target/wasm32-unknown-unknown/release/{{project-name}}.wasm", | ||
get_project_root()?.to_string_lossy() | ||
); | ||
generate_types(); | ||
let config_interface = format!("{}/{{project-name}}_serialized_config_type.txt", get_project_root()?.to_string_lossy()); | ||
let aux_data_interface = format!("{}/{{project-name}}_serialized_aux_data_type.txt", get_project_root()?.to_string_lossy()); | ||
match run_command(Some(program.into()), Some(config_interface.into()), Some(aux_data_interface.into()), Some(PROGRAM_VERSION_NUMBER)).await { | ||
let config_interface = format!( | ||
"{}/{{project-name}}_serialized_config_type.txt", | ||
get_project_root()?.to_string_lossy() | ||
); | ||
let aux_data_interface = format!( | ||
"{}/{{project-name}}_serialized_aux_data_type.txt", | ||
get_project_root()?.to_string_lossy() | ||
); | ||
|
||
let cli = Cli::parse(); | ||
let json_ouput = cli.json; | ||
match run_command( | ||
cli, | ||
Some(program.into()), | ||
Some(config_interface.into()), | ||
Some(aux_data_interface.into()), | ||
Some(PROGRAM_VERSION_NUMBER), | ||
) | ||
.await | ||
{ | ||
Ok(output) => { | ||
println!("Success: {}", output.green()); | ||
if json_ouput { | ||
println!("{}", output); | ||
} else { | ||
println!("Success: {}", output.green()); | ||
} | ||
Ok(()) | ||
} | ||
Err(err) => { | ||
println!("{}", "Failed!".red()); | ||
if !json_ouput { | ||
eprintln!("{}", "Failed!".red()); | ||
} | ||
Err(err) | ||
} | ||
} | ||
} | ||
} |