clab; – command line address book

By: Lars Wirzenius

2025-11-25 14:54

Table of Contents

1 Introduction

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

2 Empty database

1 given an installed clab
2 when I run clab lint
3 then command is successful
 
4 when I run clab search Alice
5 then command is successful
6 then stdout is exactly ""
 
7 when I try to run clab mutt-query Alice
8 then command fails

3 Alice and Bob

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

1 given an installed clab
 
2 given file .local/share/clab/address-book.yaml from address-book.yaml
 
3 when I run clab lint
4 then command is successful
 
5 when I run clab list
6 then command is successful
7 then stdout is valid YAML
8 then stdout contains "Alice Atherthon"
9 then stdout contains "Bob Bobbington"
 
10 when I run clab search Alice
11 then command is successful
12 then stdout is valid YAML
13 then stdout contains "Alice Atherthon"
14 then stdout doesn't contain "Bob"
 
15 when I run clab mutt-query Alice
16 then command is successful
17 then stdout is exactly "clab found matches: alice@example.com Alice Atherthon "
- 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
---
- 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

4 Search by tag

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

1 given an installed clab
2 given file .local/share/clab/address-book.yaml from address-book.yaml
 
3 when I run clab tagged co-worker
4 then command is successful
5 then stdout contains "Alice Atherthon"
6 then stdout doesn't contain "Bob"

5 Full text search

This scenario verifies that clab does a full text search.

1 given an installed clab
2 given file .local/share/clab/address-book.yaml from address-book.yaml
 
3 when I run clab search example
4 then command is successful
5 then stdout contains "Alice Atherthon"
6 then stdout contains "Bob"
 
7 when I run clab search email
8 then command is successful
9 then stdout contains "Alice Atherthon"
10 then stdout contains "Bob"

6 Reformat address book

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

1 given an installed clab
2 given file .local/share/clab/address-book.yaml from address-book.yaml
3 given file reformatted.yaml from address-book-reformatted
 
4 when I run clab reformat
5 then command is successful
6 then files .local/share/clab/address-book.yaml and reformatted.yaml match