clab; – command line address book

Lars Wirzenius

2022-06-18 08:13

1 Introduction

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

2 Empty database

given an installed clab
when I run clab lint
then command is successful
when I run clab search Alice
then command is successful
and stdout is exactly ""
when I try to run clab mutt-query Alice
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.

given an installed clab
and 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
and stdout is valid YAML
and stdout contains "Alice Atherthon"
and stdout contains "Bob Bobbington"
when I run clab search Alice
then command is successful
and stdout is valid YAML
and stdout contains "Alice Atherthon"
and stdout doesn't contain "Bob"
when I run clab mutt-query Alice
then command is successful
and stdout is exactly "clab found matches:\nalice@example.com\tAlice Atherthon\n"

File: address-book.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

File: address-book-reformatted

---
- 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.

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

5 Full text search

This scenario verifies that clab does a full text search.

given an installed clab
and file .local/share/clab/address-book.yaml from address-book.yaml
when I run clab search example
then command is successful
and stdout contains "Alice Atherthon"
and stdout contains "Bob"
when I run clab search email
then command is successful
and stdout contains "Alice Atherthon"
and stdout contains "Bob"

6 Reformat address book

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

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