diff --git a/templates/basic-template/Cargo.toml b/templates/basic-template/Cargo.toml index 3779291..ef305de 100644 --- a/templates/basic-template/Cargo.toml +++ b/templates/basic-template/Cargo.toml @@ -18,9 +18,12 @@ strip = "debuginfo" crate-type = ["cdylib", "rlib"] [dependencies] -entropy-programs-core={ git="https://github.com/entropyxyz/programs.git", tag="v0.10.0" } -schemars = {version = "0.8.16", optional = true} -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } +entropy-programs-core = { git = "https://github.com/entropyxyz/programs.git", tag = "v0.10.0" } +schemars = { version = "0.8.16", optional = true } +serde = { version = "1.0", default-features = false, features = [ + "alloc", + "derive", +] } # These are used by `cargo component` [package.metadata.component] diff --git a/templates/basic-template/cli/Cargo.toml b/templates/basic-template/cli/Cargo.toml index 2a7e0f5..b057ec0 100644 --- a/templates/basic-template/cli/Cargo.toml +++ b/templates/basic-template/cli/Cargo.toml @@ -3,15 +3,18 @@ name = "cli" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -clap ={ version="4.4.6", features=["derive"] } -subxt ={version = "0.35.3", features = ["substrate-compat"]} -colored ="2.0.4" -tokio ={ version="1.16", features=["macros", "rt-multi-thread", "io-util", "process"] } -anyhow ="1.0.82" +clap = { version = "4.5.20", features = ["derive"] } +subxt = { version = "0.35.3", features = ["substrate-compat"] } +colored = "2.0.4" +tokio = { version = "1.16", features = [ + "macros", + "rt-multi-thread", + "io-util", + "process", +] } +anyhow = "1.0.82" dotenv = "0.15.0" generate-types = { path = "../generate-types" } project-root = "0.2.2" -entropy-test-cli = { git="https://github.com/entropyxyz/entropy-core.git", branch = "master" } \ No newline at end of file +entropy-test-cli = { git = "https://github.com/entropyxyz/entropy-core.git", branch = "master" } diff --git a/templates/basic-template/cli/src/main.rs b/templates/basic-template/cli/src/main.rs index ed542c2..abfb492 100644 --- a/templates/basic-template/cli/src/main.rs +++ b/templates/basic-template/cli/src/main.rs @@ -1,24 +1,51 @@ +use clap::Parser; use colored::Colorize; -use entropy_test_cli::{run_command, PROGRAM_VERSION_NUMBER}; use dotenv::dotenv; +use entropy_test_cli::{run_command, Cli, 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) } } -} \ No newline at end of file +} diff --git a/templates/basic-template/generate-types/Cargo.toml b/templates/basic-template/generate-types/Cargo.toml index 7c0fd5b..a1c0529 100644 --- a/templates/basic-template/generate-types/Cargo.toml +++ b/templates/basic-template/generate-types/Cargo.toml @@ -6,6 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -program = { package= "{{project-name}}", path = "..", default-features = false, features=['std'] } +program = { package = "{{project-name}}", path = "..", default-features = false, features = [ + 'std', +] } schemars = "0.8.16" -serde_json = { version = "1.0" } \ No newline at end of file +serde_json = { version = "1.0" }