diff --git a/cmd/soroban-cli/src/commands/config/locator.rs b/cmd/soroban-cli/src/commands/config/locator.rs index 2c174a9b2d..f065f72603 100644 --- a/cmd/soroban-cli/src/commands/config/locator.rs +++ b/cmd/soroban-cli/src/commands/config/locator.rs @@ -152,6 +152,20 @@ impl Args { .collect()) } + pub fn list_identities_long(&self) -> Result, Error> { + Ok(KeyType::Identity + .list_paths(&self.local_and_global()?) + .into_iter() + .flatten() + .map(|(name, location)| { + let path = match location { + Location::Local(path) | Location::Global(path) => path, + }; + (name, format!("{}", path.display())) + }) + .collect()) + } + pub fn list_networks(&self) -> Result, Error> { Ok(KeyType::Network .list_paths(&self.local_and_global()?) diff --git a/cmd/soroban-cli/src/commands/identity/ls.rs b/cmd/soroban-cli/src/commands/identity/ls.rs index a779e72998..276232a64c 100644 --- a/cmd/soroban-cli/src/commands/identity/ls.rs +++ b/cmd/soroban-cli/src/commands/identity/ls.rs @@ -13,11 +13,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, Error> { + Ok(self.config_locator.list_identities()?) + } + + pub fn ls_l(&self) -> Result, Error> { + Ok(self + .config_locator + .list_identities_long()? + .into_iter() + .map(|(name, location)| format!("{location}\nName: {name}\n")) + .collect::>()) + } } diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index 85609f59e3..2feb731bf2 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -634,6 +634,7 @@ List identities * `--global` — Use global config * `--config-dir ` +* `-l`, `--long`