Cyrus SASL 2.1.25 introduced the sasl_callback_ft prototype,
[mmh] / docs / COMPLETION-BASH
1 # nmh completion for bash
2 # Copyright 2003 "Wade Richards" <wade@wabyn.net>
3 # Permission granted to redistribute under the BSD license
4
5 [ "$BASH_COMPLETION" ]  ||  echo "ERROR: COMPLETION-BASH is not intended to be \
6 sourced directly, but rather added to a bash-completion package installation."
7
8 have show &&
9 _nmh()
10 {
11     # args: command comp-word prev-word
12     local command current prev folder origfolder i orig_opts
13
14     COMPREPLY=()
15     current=${COMP_WORDS[COMP_CWORD]}
16     prev=${COMP_WORDS[COMP_CWORD-1]}
17     command=$1
18
19     orig_opts=$(shopt -p extglob) 
20     shopt -s extglob
21
22     # Get the folder, if specified
23     for (( i=0; i < ${#COMP_WORDS}-1; i++ ))
24     do
25         case "${COMP_WORDS[i]}" in
26         \++([a-zA-Z_]) )
27             folder=${COMP_WORDS[i]} 
28             origfolder=$( folder -f )
29             ;;
30         esac
31     done
32
33     case $current in 
34     -* ) 
35         # Command-line switches for the most common commands.
36         case $command in
37         ali ) 
38             # no sequences or messages
39             options=(-alias -list -nolist -normalize -nonormalize -user
40                     -nouser -version -help)
41             ;;
42         burst ) 
43             options=(-inplace -noinplace -quiet -noquiet -verbose
44                     -noverbose -version -help)
45             ;;
46         comp )
47             options=(-form -use -nouse -file -draftfolder -draftmessage
48                     -nodraftfolder -editor -noedit -whatnowproc -nowhatnowproc
49                     -version -help )
50            ;; 
51         flist* )
52             options=(-sequence -all -noall -showzero -noshowzero
53                     -recurse -norecurse -fast -nofast -alpha -noalpha -version
54                     -help)
55             ;;
56         folder* )
57             options=(-all -noall -create -nocreate -fast -nofast -header
58                     -noheader -recurse -norecurse -total -nototal -list -nolist
59                     -push -pop -pack -nopack -print -verbose -noverbose -version
60                     -help)
61             ;;
62         forw )
63             options=(-annotate -noannotate -form -format -noformat
64                     -filter -inplace -noinplace -mime -nomime -draftfolder
65                     -draftmessage -nodraftfolder -editor -noedit -whatnowproc
66                     -nowhatnowproc -dashstuffing -nodashstuffing -build -file
67                     -version -help)
68             ;;
69         inc )
70             options=(-audit -noaudit -changecur -nochangecur -form -format
71                     -file -silent -nosilent -truncate -notruncate -width -host
72                     -user -pack -nopack -apop -noapop -kpop -sasl -saslmech -snoop
73                     -version -help)
74             ;;
75         mark )
76             options=(-sequence -add -delete -list -public -nopublic
77                     -zero -nozero -version -help)
78             ;;
79         next )
80             options=(-showmimeproc -header -noheader -checkmime
81                     -nocheckmime -version -help)
82             ;;
83         packf )
84             options=(-file -mbox -mmdf -version -help)
85             ;;
86         pick )
87             options=(-and -or -not -lbrace -rbrace --component -cc
88                     -date -from -search -subject -to -after -before -datefield
89                     -sequence -public -nopublic -zero -nozero -list -nolist
90                     -version -help)
91             ;;
92         prev )
93             options=(-showproc -showmimeproc -header -noheader -checkmime
94                     -nocheckmime -version -help)
95             ;;
96         refile )
97             options=(-draft -link -nolink -preserve -nopreserve -unlink
98                     -nounlink -src -file -rmmproc -normmproc -version -help)
99             ;;
100         repl )
101             options=(-annotate -noannotate -group -nogroup -cc
102                     -nocc -query -noquery -form -format -noformat -filter
103                     -inplace -noinplace -mime -nomime -fcc -width -draftfolder
104                     -draftmessage -nodraftfolder -editor -noedit -whatnowproc
105                     -nowhatnowproc -build -file -version -help)
106             ;;
107         rmf )
108             options=(-interactive -nointeractive -version -help)
109             ;;
110         rmm )
111             options=(-link -nolink -version -help)
112             ;;
113         scan )
114             options=(-clear -noclear -form -format -header -noheader
115                     -width -reverse -noreverse -file -version -help )
116             ;;
117         show )
118             options=(-draft -showproc -showmimeproc -header -noheader
119                     -checkmime -nocheckmime -version -help)
120             ;;
121         sortm )
122             options=(-datefield -textfield -notextfield -limit -nolimit
123                     -verbose -noverbose -version -help)
124             ;;
125         whom )
126             options=(-alias -check -nocheck -draft -draftfolder
127                     -draftmessage -nodraftfolder -version -help)
128             ;;
129         * )
130             options=(-help -version -seq)
131             ;;
132         esac
133         ;;
134
135     +* )
136         # Folders
137         options=( $( folder -all -r -fast | grep -v "^\." | sed "s/^/+/" ) )
138         ;;
139
140     +([0-9a-z])-* )
141         # Partial range
142         start=${current/%-*/}
143         options=( $( scan $folder -format "%(msg)" "${start}-last" ) first prev cur next last )
144         options=( ${options[@]//#/${start}-} )
145         ;;
146
147     +([0-9]) )
148         # Message number, or start of range
149         options=( $( scan $folder -format "%(msg)" ) first prev cur next last )
150         options=( ${options[@]} ${options[@]//%/-} )
151         ;;
152
153     [fpcnlu]* )
154         # special message aliases
155         options=( first prev cur next last unseen )
156         ;;
157
158         # What about sequences?  I can't quite see how to get the list of possible sequences, so I
159         # guess the user will have to type them in the old-fashioned way.
160
161     esac
162
163     eval $orig_opts
164
165     COMPREPLY=( $( compgen -W "${options[*]}" -- $current ) )
166     return 0
167 }
168 [ "$have" ] && complete -F _nmh ali anno burst comp dist flist flists folder folders forw inc mark mhbuild mhl mhlist mhmail mhn mhparam mhpath mhshow mhstore msgchk msh next packf pick prev prompter rcvdist rcvpack rcvstore rcvtty  refile repl rmf rmm scan send sendfiles show slocal sortm whatnow whom