summaryrefslogtreecommitdiff
path: root/clab.md
blob: c80fdcbd5f5c8433704db608ce6d0b78e799e80a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Introduction

`clab` is a command line address book application. It has no
interactive features. This document collects its acceptance criteria.

# Empty database

~~~scenario
given an installed clab
when I run clab lint
then command is successful

when I run clab search Alice
then command is successful
then stdout is exactly ""

when I try to run clab mutt-query Alice
then command fails
~~~

# Alice and Bob

Next, let's add records for Alice and Bob, and make
sure searches find only the right records.


~~~scenario
given an installed clab

given file .local/share/clab/address-book.yaml from address-book.yaml

when I run clab lint
then command is successful

when I run clab list
then command is successful
then stdout is valid YAML
then stdout contains "Alice Atherthon"
then stdout contains "Bob Bobbington"

when I run clab search Alice
then command is successful
then stdout is valid YAML
then stdout contains "Alice Atherthon"
then stdout doesn't contain "Bob"

when I run clab mutt-query Alice
then command is successful
then stdout is exactly "clab found matches:\nalice@example.com\tAlice Atherthon\n"
~~~

~~~{#address-book.yaml .file .yaml}
- name: Alice Atherthon
  email:
    work: alice@example.com
  tags: [co-worker]
  last_checked: 2021-09
- name: Bob Bobbington
  email:
    personal: bob@example.com
  last_checked: 2021-09
~~~

~~~{#address-book-reformatted .file .yaml}
---
- name: Alice Atherthon
  email:
    work: alice@example.com
  tags:
    - co-worker
  last_checked: 2021-09
- name: Bob Bobbington
  email:
    personal: bob@example.com
  last_checked: 2021-09
~~~


# Search by tag

This scenario verifies that `clab` can find entries based on tags.

~~~scenario
given an installed clab
given file .local/share/clab/address-book.yaml from address-book.yaml

when I run clab tagged co-worker
then command is successful
then stdout contains "Alice Atherthon"
then stdout doesn't contain "Bob"
~~~

# 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"
~~~

# Reformat address book

This scenario verifies that `clab` can reformat the address book in
place.

~~~scenario
given an installed clab
given file .local/share/clab/address-book.yaml from address-book.yaml
given file reformatted.yaml from address-book-reformatted

when I run clab reformat
then command is successful
then files .local/share/clab/address-book.yaml and reformatted.yaml match
~~~