summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-10-28 06:16:36 +0000
committerLars Wirzenius <liw@liw.fi>2021-10-28 06:16:36 +0000
commit2f5d78cd7c15e118cc5cf15930cbb0635255aec4 (patch)
treebdce1644ae084b6cafc44e69b77e5dfeec2de457
parent032d2d975db7fefa45341c1c8d90975d054d379f (diff)
parent3314b4b0d0eaf75cbb53e857625583e9f73eaf60 (diff)
downloadclab-2f5d78cd7c15e118cc5cf15930cbb0635255aec4.tar.gz
Merge branch 'reformat-sort' into 'main'
feat: `clab reformat` sorts entries by name See merge request larswirzenius/clab!8
-rw-r--r--clab.md1
-rw-r--r--src/main.rs2
2 files changed, 2 insertions, 1 deletions
diff --git a/clab.md b/clab.md
index 5893fa7..2be29f6 100644
--- a/clab.md
+++ b/clab.md
@@ -1,4 +1,3 @@
-
---
title: "clab; &ndash; command line address book"
author: Lars Wirzenius
diff --git a/src/main.rs b/src/main.rs
index 8ea2a45..982cc52 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -255,6 +255,8 @@ struct Reformat {
impl Reformat {
fn run(&self, _opt: &Opt, book: &AddressBook) -> anyhow::Result<()> {
+ let mut entries: Vec<Entry> = book.entries().to_vec();
+ entries.sort_by_cached_key(|e| e.name.clone());
if self.stdout {
serde_yaml::to_writer(std::io::stdout(), book.entries())?;
} else {