addr-book-combine

command module
v0.0.0-...-11696f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

README

addr-book-combine

jasoncarloscox.com/creations/addr-book-combine

Combine multiple aerc-style address books into a single address book, with de-duplication and smart sorting.

Works well with maildir-rank-addr.

Usage

addr-book-combine (-f <file> | -c <command>) ...
  • <file> is the path to a file containing address book entries.
  • <command> is a command (to be run with sh -c) that outputs address book entries on stdout.

Each argument (-f <file> or -c <command>) is considered a separate address book. Each book contains entries, each on their own line. Entries have tab-separated fields (address<tab>name<tab>rank). Here's an example address book:

a@example.com	Andy Apple	5
b@example.com	Bart Berry	2
c@example.com	Chad Cherry	4
d@example.com

(Names and ranks are optional.)

Sorting

When comparing two addresses, a and b, which appear in books numbered i and j, respectively, the following procedure is applied:

  1. First, if the addresses are not from the same book, the address from the earlier book appears first.

  2. Next, each book is checked to compare the addresses:

    • If neither address is ranked within the book, check in the next book.
    • If only one address is ranked within the book, the ranked address appears first.
    • If both addresses have the same rank, check in the next book.
    • If the addresses have different ranks, the address with the lowest rank appears first.
  3. Finally, if no address has been chosen to appear first, preserve the original order of the addresses.

Check out the test code to see some examples.

Building & Running

go build
./addr-book-combine

Testing

go test

Contributing

Contributions are welcome! You can send questions, bug reports, patches, etc. by email to ~jcc/public-inbox@lists.sr.ht. (Don't know how to contribute via email? Check out the interactive tutorial at git-send-email.io, or email me for help.)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL