diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-07-22 07:10:13 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-07-22 07:10:13 +0000 |
commit | 85c3341aedb22ac2d2a2a1123a061b76b4f65fe3 (patch) | |
tree | f1a2dfd6e9f269598a09638c2087a3ce1e1e4918 | |
parent | c03d919a68676eb321d9e4505bfeb5829884e924 (diff) | |
parent | 4ed01e03bfabb2714c9b108cc5ac9aaa06ca2327 (diff) | |
download | clab-85c3341aedb22ac2d2a2a1123a061b76b4f65fe3.tar.gz |
Merge branch 'fulltext' into 'main'
feat: do full text search
Closes #2
See merge request larswirzenius/clab!2
-rw-r--r-- | clab.md | 19 | ||||
-rw-r--r-- | src/main.rs | 3 |
2 files changed, 21 insertions, 1 deletions
@@ -59,6 +59,25 @@ then stdout is exactly "clab found matches:\nalice@example.com\tAlice Atherthon\ ~~~ +# Full text search + +This scenario verifies that `clab` does a full text search. + +~~~scenario +given an installed clab +given file .local/share/clab/address-book.yaml from address-book.yaml + +when I run clab search example +then command is successful +then stdout contains "Alice Atherthon" +then stdout contains "Bob" + +when I run clab search email +then command is successful +then stdout contains "Alice Atherthon" +then stdout contains "Bob" +~~~ + --- title: "clab; – command line address book" author: Lars Wirzenius diff --git a/src/main.rs b/src/main.rs index b8645d5..d5ae5c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,7 +46,8 @@ struct Entry { impl Entry { fn is_match(&self, needle: &str) -> bool { - contains(&self.name, needle) + let text = serde_yaml::to_string(self).unwrap(); + contains(&text, needle) } fn emails(&self) -> Vec<String> { |