soroban_cli/commands/cache/actionlog/
ls.rs1use crate::config::{data, locator};
2
3#[derive(thiserror::Error, Debug)]
4pub enum Error {
5 #[error(transparent)]
6 Config(#[from] locator::Error),
7 #[error(transparent)]
8 Data(#[from] data::Error),
9}
10
11#[derive(Debug, clap::Parser, Clone)]
12#[group(skip)]
13pub struct Cmd {
14 #[command(flatten)]
15 pub config_locator: locator::Args,
16
17 #[arg(long, short = 'l')]
18 pub long: bool,
19}
20
21impl Cmd {
22 pub fn run(&self) -> Result<(), Error> {
23 let res = if self.long { self.ls_l() } else { self.ls() }?.join("\n");
24 println!("{res}");
25 Ok(())
26 }
27
28 pub fn ls(&self) -> Result<Vec<String>, Error> {
29 Ok(data::list_ulids()?
30 .iter()
31 .map(ToString::to_string)
32 .collect())
33 }
34
35 pub fn ls_l(&self) -> Result<Vec<String>, Error> {
36 Ok(data::list_actions()?
37 .iter()
38 .map(ToString::to_string)
39 .collect())
40 }
41}