From 948596c33b9bd4d8b57c8ab077512c08679c1900 Mon Sep 17 00:00:00 2001 From: jolestar Date: Wed, 6 Sep 2023 09:47:44 +0800 Subject: [PATCH] [CLI] set error_prefix to Error (#728) * [CLI] set error_prefix to Error * [gh-664 and gh-663] add error prefix condition. --------- Co-authored-by: Feliciss <10203-feliciss@users.noreply.0xacab.org> --- crates/rooch/src/commands/move_cli/mod.rs | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/crates/rooch/src/commands/move_cli/mod.rs b/crates/rooch/src/commands/move_cli/mod.rs index 350279019e..6f1becebc1 100644 --- a/crates/rooch/src/commands/move_cli/mod.rs +++ b/crates/rooch/src/commands/move_cli/mod.rs @@ -69,10 +69,30 @@ impl CommandAction for MoveCli { .execute(move_args.package_path, move_args.build_config) .map(|_| "Success".to_owned()) .map_err(RoochError::from), - MoveCommand::Errmap(c) => c - .execute(move_args.package_path, move_args.build_config) - .map(|_| "Success".to_owned()) - .map_err(RoochError::from), + MoveCommand::Errmap(mut c) => { + match c.error_prefix { + Some(prefix) => { + if prefix == "Error" { + c.error_prefix = Some("Error".to_owned()); + } else if prefix == "E" { + c.error_prefix = Some("E".to_owned()); + } else { + return Err(RoochError::CommandArgumentError( + "Invalid error prefix. Use --error-prefix \"E\" for move-stdlib, --error-prefix \"Error\" for moveos-stdlib and rooch-framework, etc.".to_owned(), + )); + } + } + None => { + return Err(RoochError::CommandArgumentError( + "Error prefix not provided. Use --error-prefix \"E\" for move-stdlib, --error-prefix \"Error\" for moveos-stdlib and rooch-framework, etc.".to_owned(), + )); + } + } + + c.execute(move_args.package_path, move_args.build_config) + .map(|_| "Success".to_owned()) + .map_err(RoochError::from) + } MoveCommand::Info(c) => c .execute(move_args.package_path, move_args.build_config) .map(|_| "Success".to_owned())