kontaktdb

Store, retrieve, and edit basic contact information in plain text.
git clone https://git.sr.ht/~jbauer/kontaktdb
Log | Files | Refs | README | LICENSE

commit 9ab434204e9fd69e1cb25b7c5fe77034115c1090
parent dfcd3b3599b10944bf4c82617e21b8a6d5eda98d
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Sun, 14 Jun 2020 15:54:37 -0400

Rearrange variables in source code

The flow of the source code is now:
1. Environment setting/checking
2. Variable definition
3. Functions
4. Main program logic

Which, I think, is easier to understand as a whole. It also moves the
big helptext block from in between the functions and main program logic
to before all of that which makes it easier to jump back and forth
between the two sections.

Diffstat:
Mkontaktdb | 84++++++++++++++++++++++++++++++++++++++++----------------------------------------
1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/kontaktdb b/kontaktdb @@ -31,9 +31,50 @@ else database="$HOME"/.kontaktdb fi -queryfile="/tmp/kontaktdb-query-results.txt" touch $database +queryfile="/tmp/kontaktdb-query-results.txt" +name="" # Intentionally blank +email="" # Intentionally blank +query="" # Intentionally blank + +helptext=$(cat << EOF +kontaktdb - Store, retrieve, and edit contact information in plain text + +Usage: kontaktdb {action} [arguments] + +Available actions: +-h|--help show brief help and exit +-v|--version print kontaktdb's version number and exit +-a|--add <name> <email> add a contact to the database +-c|--change <query> <name> <email> change an existing contact's information +-r|--retrive <query> retrieve a contact's information +-d|--delete <query> delete a contact +-l|--list list all contacts in the database + +Friendly names of actions can also be used. E.g. 'kontaktdb add' is valid. + +Arguments: +<query> the string to search the database for +<name> the contact's name +<email> the contact's email + +Examples: + + $ kontaktdb -a "John Smith" "john.smith@example.com" + New contact added to database + + $ kontaktdb -r john + john.smith@example.com John Smith + + $ kontaktdb -c john "John Doe" "john.doe@example.com" + Contact information changed + + $ kontaktdb -d john + Contact deleted from database +EOF +) + # Escapes all special BRE characters which could appear in a returned entry escape_entry() { @@ -82,47 +123,6 @@ change_contact() echo "Contact information changed" } -helptext=$(cat << EOF -kontaktdb - Store, retrieve, and edit contact information in plain text - -Usage: kontaktdb {action} [arguments] - -Available actions: --h|--help show brief help and exit --v|--version print kontaktdb's version number and exit --a|--add <name> <email> add a contact to the database --c|--change <query> <name> <email> change an existing contact's information --r|--retrive <query> retrieve a contact's information --d|--delete <query> delete a contact --l|--list list all contacts in the database - -Friendly names of actions can also be used. E.g. 'kontaktdb add' is valid. - -Arguments: -<query> the string to search the database for -<name> the contact's name -<email> the contact's email - -Examples: - - $ kontaktdb -a "John Smith" "john.smith@example.com" - New contact added to database - - $ kontaktdb -r john - john.smith@example.com John Smith - - $ kontaktdb -c john "John Doe" "john.doe@example.com" - Contact information changed - - $ kontaktdb -d john - Contact deleted from database -EOF -) - -name="" -email="" -query="" - while test $# -gt 0; do case "$1" in -h|--help|help)