diff --git a/gcli/src/cmd/program.rs b/gcli/src/cmd/program.rs index 7020daa8868..94d8c49fab2 100644 --- a/gcli/src/cmd/program.rs +++ b/gcli/src/cmd/program.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . //! Command `program`. -use crate::{meta::Meta, result::Result, utils, App}; +use crate::{meta::Meta, result::Result, App}; use clap::Parser; use gsdk::{ext::sp_core::H256, Api}; use std::{fs, path::PathBuf}; @@ -33,8 +33,8 @@ pub enum Program { /// /// - "*.meta.txt" describes the metadata of the program /// - "*.meta.wasm" describes the wasm exports of the program - #[arg(short, long)] - meta: Option, + #[cfg_attr(feature = "embed", clap(skip))] + meta: PathBuf, /// Overridden metadata binary if feature embed is enabled. #[clap(skip)] meta_override: Vec, @@ -98,7 +98,7 @@ impl Program { meta_override, } => { let meta = if meta_override.is_empty() { - Self::resolve_meta(&utils::meta_path(meta.clone(), "meta")?) + Self::resolve_meta(meta) } else { Meta::decode_wasm(meta_override) }?; diff --git a/gcli/src/utils.rs b/gcli/src/utils.rs index 79eb1557244..8630ecffc39 100644 --- a/gcli/src/utils.rs +++ b/gcli/src/utils.rs @@ -20,7 +20,7 @@ use crate::result::Result; use anyhow::anyhow; -use std::{env, fs, path::PathBuf}; +use std::{fs, path::PathBuf}; /// home directory of cli `gear` pub fn home() -> PathBuf { @@ -33,26 +33,6 @@ pub fn home() -> PathBuf { home } -/// Parse the metadata path with result. -pub fn meta_path(meta: Option, opt: &str) -> Result { - if let Some(meta) = meta { - return Ok(meta); - } - - let cwd = env::current_dir()?; - for entry in fs::read_dir(&cwd)? { - let file = entry?.path(); - if file.ends_with(".meta.wasm") { - return Ok(file); - } - } - - Err(anyhow!( - "Could not find any *.meta.wasm in {cwd:?}, please specify the metadata path with --{opt}", - ) - .into()) -} - pub trait Hex { fn to_vec(&self) -> Result>; fn to_hash(&self) -> Result<[u8; 32]>; diff --git a/gcli/tests/gear.rs b/gcli/tests/gear.rs index 31a68c0ec08..eb7e3de0d4d 100644 --- a/gcli/tests/gear.rs +++ b/gcli/tests/gear.rs @@ -26,7 +26,7 @@ mod common; #[tokio::test] async fn api_timeout() { assert!(matches!( - Api::new_with_timeout(None, Some(1)).await.err(), + Api::new_with_timeout(None, Some(0)).await.err(), Some(Error::SubxtRpc(jsonrpsee::core::Error::Transport(..))) )); }