Skip to content

Commit

Permalink
Update template CLI for latest changes to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Nov 13, 2024
1 parent c689ad3 commit 4618d44
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions templates/basic-template/cli/src/main.rs
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)
}
}
}
}

0 comments on commit 4618d44

Please sign in to comment.