From 0c1fd7087c50fc6e93725b18ef283aa01eb07693 Mon Sep 17 00:00:00 2001 From: German Lashevich Date: Fri, 23 Mar 2018 00:38:45 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Sorted=20applications=20list=20on?= =?UTF-8?q?=20dashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/totp.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin/totp.rs b/src/bin/totp.rs index 8fb6297..c3976f7 100644 --- a/src/bin/totp.rs +++ b/src/bin/totp.rs @@ -132,6 +132,9 @@ impl Cli { println!("I won't tell anyone about this 🤫"); std::process::exit(0); }).expect("Error setting Ctrl-C handler"); + // Prepare sorted keys for displaying apps in order + let mut keys: Vec = apps.keys().map(|key| key.clone()).collect(); + keys.sort(); loop { if is_first_iteration { is_first_iteration = false; @@ -139,7 +142,8 @@ impl Cli { print!("\x1B[{}A", lines_count); } Self::print_progress_bar(); - for (_, app) in apps { + for key in keys.iter() { + let app = &apps[key]; println!{"{:06} {}", app.get_code(), app.get_name()}; } thread::sleep(Duration::from_millis(100));