Skip to content

Commit

Permalink
fix: add actionlog subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed May 1, 2024
1 parent 8b4d359 commit c745de7
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
30 changes: 30 additions & 0 deletions cmd/soroban-cli/src/commands/cache/actionlog/mod.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
23 changes: 9 additions & 14 deletions cmd/soroban-cli/src/commands/cache/mod.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
Expand Down

0 comments on commit c745de7

Please sign in to comment.