commit f59b6ddb7d28db083504a0dd9b883dd4ab568370
parent c31ea725db8717363d48c57cdaee54864b5610f9
Author: Jaromil <jaromil@dyne.org>
Date: Sun, 25 Jan 2015 15:24:06 +0100
revamped zsh completion (now lists even remote imap folders) and better documentation
Diffstat:
8 files changed, 133 insertions(+), 120 deletions(-)
diff --git a/doc/jaromail-manual.org b/doc/jaromail-manual.org
@@ -552,7 +552,7 @@ Here a roundup on the addressbook commands that are available from the /jaro/ co
| *extract* | gpg keyring | print address list of gpg public keyring |
| *extract* | gpg pubkey | print address list of gpg key signatures |
| *extract* | vcard file | print address list of entries in VCard file |
-| *vcard* | | print VCard from address list on stdin |
+| *vcard* | vcard file | export the addressbook into a VCard file |
| *import* | -l listname | import address list from stdin to addressbook |
| *import* | filename | import address list into an address list file |
| *search addr* | (-l) string | print address list of matches in addressbook |
diff --git a/src/completion/README b/extras/shell_completion/README
diff --git a/extras/shell_completion/_jaromail b/extras/shell_completion/_jaromail
@@ -0,0 +1,74 @@
+#compdef jaro
+
+# Zsh completion for jaromail
+
+# location hardcoded is Mail
+jarodir=${JAROMAILDIR:-${HOME}/Mail}
+
+_jaromail() {
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+ typeset -alU results
+
+ _arguments \
+ '1: :->commands'\
+ '*: :->args'
+
+ case $state in
+ commands)
+ _arguments '1:Commands:(open compose fetch send peek search passwd abook extract import backup merge update filter)'
+ ;;
+ *)
+ _last=$(( ${#words} - 1 ))
+ case $words[$_last] in
+
+ '-a')
+ # for f in `find $jarodir/Accounts -type f | grep -v 'README*'`; do
+ # c=`basename ${f}`
+ # compadd "$@" "$c"
+ # done
+ _acs=(`ls $jarodir/Accounts | grep -v README`)
+ compadd -a _acs
+ ;;
+
+ '-l')
+ _abs=(`ls $jarodir/*.abook`)
+ # for f in `find $jarodir/ -maxdepth 1 -type f -name '*.abook'`; do
+ # c=`basename ${f}`
+ # compadd "$@" "${c[(ws:.:)1]}"
+ # done
+ compadd -a _abs
+ ;;
+
+ fetch|peek)
+ _fds=(`jaro imap listfolders 2>/dev/null`)
+ compadd -a _fds
+ ;;
+
+ open|filter|backup|merge)
+ _mds=(`ls -d $jarodir/*`)
+ md=()
+ for m in $_mds; do
+ [[ -r "$m/cur" ]] && \
+ md+=(${m:t})
+ done
+ _multi_parts . md
+ ;;
+
+ compose)
+ _adrs=("${(@f)$(jaro search addr . 2>/dev/null)}")
+ compadd -X "Recipient addresses:" -a _adrs
+ ;;
+
+ *)
+ _files
+ ;;
+ esac
+ esac
+}
+
+_jaromail "$@"
+
+# Local Variables:
+# mode: sh
+# End:
diff --git a/src/completion/jaromail.bash b/extras/shell_completion/jaromail.bash
diff --git a/src/completion/_jaromail b/src/completion/_jaromail
@@ -1,61 +0,0 @@
-#compdef jaro
-
-# Zsh completion for jaromail
-
-# location hardcoded is Mail
-jarodir=${HOME}/Mail
-
-_jaromail() {
- local curcontext="$curcontext" state line
- typeset -A opt_args
- typeset -alU results
-
- _arguments \
- '1: :->commands'\
- '*: :->args'
-
- case $state in
- commands)
- _arguments '1:Commands:(fetch send peek compose open)'
- ;;
- *)
- case $words[2] in
-
- open|filter|search|backup|merge)
- for f in `ls $jarodir`; do
- compadd "$@" "$f"; done
- ;;
-
- fetch|peek)
- for f in `find $jarodir/jaro/Accounts -name 'imap.*'`; do
- c=`basename ${f}|cut -d. -f2`
- compadd "$@" "$c"
- done
- ;;
-
- send)
- for f in `find $jarodir/jaro/Accounts -name 'smtp.*'`; do
- c=`basename ${f}|cut -d. -f2`
- compadd "$@" "$c"
- done
- ;;
-
- compose)
- _files
- # typeset -alU names
- # names=`echo ".width 64 128
- # SELECT email, name FROM whitelist
- # WHERE name LIKE \"%$1%\"; \
- # SELECT email, name FROM whitelist
- # WHERE email LIKE \"%$1%\";" \
- # | sqlite3 -batch ${jarodir}/jaro/addressbook`
- # for n in ${(f)names}; do
- # compadd "$@" "${n[(ws:|:)2]} <${n[(ws:|:)1]}>"
- # done
- ;;
- *) ;;
- esac
- esac
-}
-
-_jaromail "$@"-
\ No newline at end of file
diff --git a/src/jaro b/src/jaro
@@ -440,78 +440,61 @@ Main commands:
fetch download unread emails from [account]
send send all mails queued in the outbox
peek look into the [account] mailbox without downloading
- search search maildirs or addressbook for strings
+ index build or update the search index for all maildirs
+ search search maildirs or addressbook for expressions
Options:
- -a use a particular account instead of default (filename)
- -l what list to use on Addressbook operations: white or black
-
- -h print this help
- -v version information for this tool
- -q run quietly without printing information
+ -a use a particular [account] instead of default
+ -l set [abook] in use, 'whitelist' is default
-n dry run, show operations without executing them
+ -q run quietly without printing information
-D print debugging information at runtime
+ -v version information for this tool
+ -h print this help
-== Addressbook commands (use -l to indicate which addressbook $list)
+== Addressbook commands (use -l to indicate which addressbook)
a pipe | in front indicate they take an email body from stdin
- import import entries from a VCard file in the $list
-
- export export the $list to a VCard file
-
- abook edit the $list using abook terminal console editor
-
-|learn learn addresses from mails piped in stdin
-
- list prints to console all the entries in $list
+ abook edit the [abook] using the console editor
- index index fetched email archives for search
+ extract list addresses of all recipients or senders found in:
+ maildir, search expr, vcard, gnupg keyring or pubkey
- search search using a string parameter
+|import read address list from stdin into addressbook or group
+ (the output of extract commands can be piped to import)
-|isknown read e-mail from stdin, return 0 if sender is known
- extract list all recipients or senders found in a maildir
+== Operational commands (use -a to indicate [account])
-== Operational commands (use -a to indicate which $account)
-account names correspond to the filenames, i.e. imap.default
+ fetch downloads emails locally from [account]
- fetch downloads emails locally from an $account on-line
- option "keep" (default) to avoid deleting from servers
+ send send all outbox/ queue via the [account]'s smtp
- send send all emails queued in outbox/ to an smtp.$account
+ peek interactive connection to an [account]'s imap folder
+ (takes folder names as argument, default is INBOX)
- peek connect to an imap folder with ncurses terminal mutt
- use for server-side operations on emails without download
+ passwd set [account]'s passwords in the OS native keyring
- passwd set account passwords in the OS native keyring
- or into a simple, file based, gpg encrypted database.
+|queue read a mail from stdin and queue it in outbox/ for sending
-|queue queue a mail in outbox/ for send
+|smtp read a mail from stdin and send it via [accounts]'s smtp
-== Storage commands (all take path to maildirs as arguments + mairix)
-(mairix) commandline parsed intuitive expressions for date and strings
-maildirs are directories of mails downloaded in Mail/
+== Storage commands
open open a maildir folder (can use -R for read-only)
- backup (mairix) move mails from a maildir to another one
- match mails to move based on date ranges or strings
+ backup move search results from a maildir to another one
+ (string or date range matches, can use -n for dry-run)
- rmdupes remove all duplicated e-mails into a maildir
+ merge merge a source maildir into destination, then delete source
- merge merge a maildir into another, removing all duplicates
+ update updates all filter engine according to Filters.txt
+ (also generates Sieve format rules ready for server use)
- filter passes a maildir through the configured and updated Filters.txt
-
- update updates Filters.txt generating rules (sieve format)
-
-Experimental commands:
-
- stat prints a statistical overview on stored maildirs
- cert import most common SSL certificates from the Internet
+ filter process a maildir distributing emails according to Filters.txt
+ (if none specified, processes incoming/ - called by fetch)
For a complete introductory documentation, see the User Manual (PDF)
Website on <http://dyne.org/software/jaro-mail>
@@ -560,6 +543,7 @@ main() {
subcommands_opts[import]=""
subcommands_opts[export]=""
+ subcommands_opts[vcard]=""
subcommands_opts[abook]=""
subcommands_opts[vim]=""
@@ -597,6 +581,7 @@ main() {
subcommands_opts[cryptsign]=""
subcommands_opts[isml]=""
+ subcommands_opts[ismd]=""
### Detect subcommand
local -aU every_opts #every_opts behave like a set; that is, an array with unique elements
@@ -746,7 +731,7 @@ main() {
exitcode=$?
;;
- stat) stats ${PARAM} ;;
+# stat) stats ${PARAM} ;;
complete) complete ${PARAM}
@@ -765,6 +750,10 @@ main() {
exitcode=$?
;;
+ vcard)
+ export_vcard ${PARAM}
+ ;;
+
"export")
case "$PARAM" in
abook)
@@ -815,6 +804,7 @@ main() {
isonline) is_online ${=PARAM}; exitcode=$? ;;
+
publish)
md="$1"
{ maildircheck "$md" 2>/dev/null } || { md="${MAILDIRS}/${md}" }
@@ -883,6 +873,13 @@ main() {
exitcode=$?
;;
+ ismd)
+ maildircheck ${PARAM}
+ [[ $? = 0 ]] && \
+ notice "Directory is a maildir: ${PARAM}"
+ exitcode=$?
+ ;;
+
*) # unknown command, pass it to autostart
func "unknown command, remote check"
autostart ${PARAM}
diff --git a/src/zlibs/addressbook b/src/zlibs/addressbook
@@ -412,6 +412,7 @@ extract() {
done
notice "Unique addresses found: ${#result}"
+ act "calculating known and new addresses..."
# counts which addresses are known to us
_known=0
for i in ${(k)result}; do
@@ -459,6 +460,7 @@ extract() {
done
notice "Unique addresses found: ${#result}"
+ act "calculating known and new addresses..."
# counts which addresses are known to us
_known=0
for i in ${(k)result}; do
@@ -528,6 +530,7 @@ BEGIN { newcard=0; c=0; name=""; email=""; }
done
notice "Unique addresses found: ${#result}"
+ act "calculating known and new addresses..."
# counts which addresses are known to us
_known=0
for i in ${(k)result}; do
@@ -730,11 +733,12 @@ EOF
# export addressbook to vcard
export_vcard() {
+ _out=${1:-"$MAILDIRS"/$list.vcf}
abook --convert --informat abook \
--infile "$ADDRESSBOOK" \
- --outformat gcrd --outfile "$MAILDIRS"/$list.vcf
+ --outformat gcrd --outfile $_out
_res=$?
- [[ $_res = 0 ]] && notice "$list addressbook exported to VCard file $MAILDIRS/$list.vcf"
+ [[ $_res = 0 ]] && notice "$list addressbook exported to VCard file $_out"
return $_res
}
diff --git a/src/zlibs/maildirs b/src/zlibs/maildirs
@@ -29,16 +29,16 @@ typeset -h formail_cache
# no in all other cases
maildircheck() {
{ test -r "$1" } || {
- error "Maildir not existing: $1"
- return 1 }
+ error "Maildir not existing: $1"
+ return 1 }
{ test -w "$1" } || {
- error "Directory not writable: $1"
- return 1 }
+ error "Directory not writable: $1"
+ return 1 }
{ test -r "$1/cur" } \
- && { return 0 } # Yes is a maildir
-# shortened test to speedup
-# && { test -r $1/new } \
-# && { test -r $1/tmp } \
+ && { return 0 } # Yes is a maildir
+ # shortened test to speedup
+ # && { test -r $1/new } \
+ # && { test -r $1/tmp } \
func "Not a maildir: $1"
return 1
}