From c745de7894384c49c8704616d623a7d4e8596ace Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Wed, 1 May 2024 19:07:31 -0400 Subject: [PATCH] fix: add actionlog subcommand --- .../tests/it/integration/hello_world.rs | 1 + .../src/commands/cache/{ => actionlog}/ls.rs | 2 +- .../src/commands/cache/actionlog/mod.rs | 30 +++++++++++++++++++ .../commands/cache/{ => actionlog}/read.rs | 2 +- cmd/soroban-cli/src/commands/cache/mod.rs | 23 ++++++-------- 5 files changed, 42 insertions(+), 16 deletions(-) rename cmd/soroban-cli/src/commands/cache/{ => actionlog}/ls.rs (95%) create mode 100644 cmd/soroban-cli/src/commands/cache/actionlog/mod.rs rename cmd/soroban-cli/src/commands/cache/{ => actionlog}/read.rs (97%) diff --git a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs index a6e8d863a..be03afa8d 100644 --- a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs +++ b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs @@ -66,6 +66,7 @@ async fn invoke() { extend_contract(sandbox, id).await; let uid = sandbox .new_assert_cmd("cache") + .arg("actionlog") .arg("ls") .assert() .stdout_as_str(); diff --git a/cmd/soroban-cli/src/commands/cache/ls.rs b/cmd/soroban-cli/src/commands/cache/actionlog/ls.rs similarity index 95% rename from cmd/soroban-cli/src/commands/cache/ls.rs rename to cmd/soroban-cli/src/commands/cache/actionlog/ls.rs index 05d99bb7e..cb7a958c6 100644 --- a/cmd/soroban-cli/src/commands/cache/ls.rs +++ b/cmd/soroban-cli/src/commands/cache/actionlog/ls.rs @@ -1,6 +1,6 @@ use clap::command; -use super::super::config::locator; +use super::super::super::config::locator; use crate::commands::config::data; #[derive(thiserror::Error, Debug)] diff --git a/cmd/soroban-cli/src/commands/cache/actionlog/mod.rs b/cmd/soroban-cli/src/commands/cache/actionlog/mod.rs new file mode 100644 index 000000000..cb7549609 --- /dev/null +++ b/cmd/soroban-cli/src/commands/cache/actionlog/mod.rs @@ -0,0 +1,30 @@ +use clap::Parser; + +pub mod ls; +pub mod read; + +#[derive(Debug, Parser)] +pub enum Cmd { + /// List cached actions (transactions, simulations) + Ls(ls::Cmd), + /// Read cached action + Read(read::Cmd), +} + +#[derive(thiserror::Error, Debug)] +pub enum Error { + #[error(transparent)] + Ls(#[from] ls::Error), + #[error(transparent)] + Read(#[from] read::Error), +} + +impl Cmd { + pub fn run(&self) -> Result<(), Error> { + match self { + Cmd::Ls(cmd) => cmd.run()?, + Cmd::Read(cmd) => cmd.run()?, + }; + Ok(()) + } +} diff --git a/cmd/soroban-cli/src/commands/cache/read.rs b/cmd/soroban-cli/src/commands/cache/actionlog/read.rs similarity index 97% rename from cmd/soroban-cli/src/commands/cache/read.rs rename to cmd/soroban-cli/src/commands/cache/actionlog/read.rs index 88be5b7b0..b3f6bc57f 100644 --- a/cmd/soroban-cli/src/commands/cache/read.rs +++ b/cmd/soroban-cli/src/commands/cache/actionlog/read.rs @@ -6,7 +6,7 @@ use std::{ use clap::ValueEnum; use ulid::Ulid; -use super::super::config::locator; +use super::super::super::config::locator; use crate::commands::config::data; #[derive(thiserror::Error, Debug)] diff --git a/cmd/soroban-cli/src/commands/cache/mod.rs b/cmd/soroban-cli/src/commands/cache/mod.rs index db629db10..32302e9d3 100644 --- a/cmd/soroban-cli/src/commands/cache/mod.rs +++ b/cmd/soroban-cli/src/commands/cache/mod.rs @@ -1,41 +1,36 @@ use clap::Parser; +pub mod actionlog; pub mod clean; pub mod info; -pub mod ls; -pub mod read; #[derive(Debug, Parser)] pub enum Cmd { - /// List cached actions (transactions, simulations) - Ls(ls::Cmd), - /// Show location of cache - Info(info::Cmd), + /// Access details about (transactions, simulations) + #[command(subcommand)] + Actionlog(actionlog::Cmd), /// Delete all cached actions Clean(clean::Cmd), - /// Read cached action - Read(read::Cmd), + /// Show location of cache + Info(info::Cmd), } #[derive(thiserror::Error, Debug)] pub enum Error { #[error(transparent)] - Info(#[from] info::Error), - #[error(transparent)] - Ls(#[from] ls::Error), + Actionlog(#[from] actionlog::Error), #[error(transparent)] Clean(#[from] clean::Error), #[error(transparent)] - Read(#[from] read::Error), + Info(#[from] info::Error), } impl Cmd { pub fn run(&self) -> Result<(), Error> { match self { - Cmd::Ls(cmd) => cmd.run()?, + Cmd::Actionlog(cmd) => cmd.run()?, Cmd::Info(cmd) => cmd.run()?, Cmd::Clean(cmd) => cmd.run()?, - Cmd::Read(cmd) => cmd.run()?, }; Ok(()) }