Write an awk script to query abook's ini file (a simple crm on the command-line)
I am looking for a CRM (Customer Relation Management) programme on the cli on Trisquel.
Because I already use abook to store my contacts, I am wondering if I could use awk to query abook's ini file 'addressbook'.
Here are specifications I have in mind:
1. possibility to tag contacts e.g. 'client', 'distribution', 'iteration_1', 'supplier', etc
I imagine I can use abook's custom fields to tag contacts; I am not sure if it's best to input one tag per custom field, or if I should store all the tags in a single custom field; I might ask this question on abook's mailing list.
2. query the file 'addressbook' by tag, city, company etc.
3. return the output of the query via abook interface[1]
That's where I'm at right now; I've hard-coded the query:
#!/usr/bin/env bash
awk '
BEGIN {
RS = "";
FS = "\n"
}
/'city*.*London'/
' file
This returns all the records for which the field 'city' is 'London'.
My next step is to figure out how to pass the field (e.g. city) and the argument (e.g. London); so, say, if the script is called 'crm', I can run:
$ ./crm city london
then abook displays all contacts for which the field 'city' equals 'London', or 'london'.
Same for tags, maybe I could have something like this:
$ ./crm tag supplier
then abook displays all contacts for which the field 'tag' (or custom field idk) equals 'supplier'.
That's the idea; I have no idea whether I am on the right path.
Feedback welcome.
I am reading through https://www.gnu.org/software/gawk/manual/gawk.html to try to find the information I need to move on, about passing arguments to an awk script.
---
[1] I am thinking of this because I read this in abook's mailing list:
> another idea: you might want to keep your contacts in a yaml file and then generate your abook datafiles dynamically from those using whatever scripting language you are most comfortable with (I personally would prefer perl over awk).[2]
[2] https://sourceforge.net/p/abook/mailman/message/32527292/
PS: I found /crm-cli on github; the maintainer still uses it, but I'm reluctant to consider it because I already have all my contacts in abook.
- Vous devez vous identifier ou créer un compte pour écrire des commentaires