Skip to content

Commit

Permalink
Add a long ls option to config identity command
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Nov 22, 2023
1 parent 893f830 commit 001ba51
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cmd/soroban-cli/src/commands/config/identity/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,28 @@ pub enum Error {
pub struct Cmd {
#[command(flatten)]
pub config_locator: locator::Args,

#[arg(long, short = 'l')]
pub long: bool,
}

impl Cmd {
pub fn run(&self) -> Result<(), Error> {
println!("{}", self.config_locator.list_identities()?.join("\n"));
let res = if self.long { self.ls_l() } else { self.ls() }?.join("\n");
println!("{res}");
Ok(())
}

pub fn ls(&self) -> Result<Vec<String>, Error> {
Ok(self.config_locator.list_identities()?)
}

pub fn ls_l(&self) -> Result<Vec<String>, Error> {
Ok(self
.config_locator
.list_identities_long()?
.into_iter()
.map(|(name, location)| format!("{location}\nName: {name}\n"))
.collect::<Vec<String>>())
}
}

0 comments on commit 001ba51

Please sign in to comment.