From 32db6b408b9a3070795f7a29ba5c429471fb056b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 19 Apr 2020 05:33:19 -0400 Subject: sort the rbw list output --- src/bin/rbw/commands.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/bin/rbw/commands.rs') diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index 81ea2e2..75ab8e3 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -82,12 +82,17 @@ pub fn list() -> anyhow::Result<()> { let email = config_email()?; let db = rbw::db::Db::load(&email) .context("failed to load password database")?; - for entry in db.entries { - println!( - "{}", - crate::actions::decrypt(&entry.name) - .context("failed to decrypt entry name")? - ); + + let mut ciphers: Vec = db + .entries + .iter() + .cloned() + .map(|entry| decrypt_cipher(&entry)) + .collect::>()?; + ciphers.sort_unstable_by(|a, b| a.name.cmp(&b.name)); + + for cipher in ciphers { + println!("{}", cipher.name); } Ok(()) -- cgit v1.2.3-54-g00ecf