|
@@ -14,19 +14,12 @@ usage() {
|
14
|
14
|
mkusage "$@" "[options] ACTION" \
|
15
|
15
|
-o \
|
16
|
16
|
"-c DIR change to DIR before doing anything" \
|
|
17
|
+ "-l list handlers and exit" \
|
17
|
18
|
"-d turn on debugging mode" \
|
18
|
19
|
-- \
|
19
|
20
|
"imapdomo will try to read init.lua and handlers/ACTION.lua from its" \
|
20
|
21
|
"configuration directory." \
|
21
|
22
|
"" \
|
22
|
|
- "four valid actions are understood; since you must write handler for" \
|
23
|
|
- "each action you want to use, the meanings below are purely a guide:" \
|
24
|
|
- "" \
|
25
|
|
- " newmail - check for and file new mail" \
|
26
|
|
- " rewind - re-add messages from FILTER_FAIL back to FILTER_QUEUE" \
|
27
|
|
- " cleanup - delete or archive old messages" \
|
28
|
|
- " migrate - move mail between mailboxes" \
|
29
|
|
- "" \
|
30
|
23
|
"See imapfilter_config(5)) for guide and API reference. Few functions"\
|
31
|
24
|
"are also available in .imapdomo/common.lua"
|
32
|
25
|
}
|
|
@@ -58,6 +51,14 @@ show_semversion() {
|
58
|
51
|
exit 0
|
59
|
52
|
}
|
60
|
53
|
|
|
54
|
+lshandlers() {
|
|
55
|
+ #
|
|
56
|
+ # List recognized handlers
|
|
57
|
+ #
|
|
58
|
+ find "$IMAPDOMO_HOME/handlers" -name "*.lua" -printf "%f\n" \
|
|
59
|
+ | sed 's/.lua$//'
|
|
60
|
+}
|
|
61
|
+
|
61
|
62
|
main() {
|
62
|
63
|
local Action # what to do
|
63
|
64
|
local Debug # true if debugging
|
|
@@ -74,14 +75,15 @@ main() {
|
74
|
75
|
while true; do case $1 in
|
75
|
76
|
-c) CdTo="$2"; shift 2 || usage -w "missing value to: $1" ;;
|
76
|
77
|
-d) Debug=true; PRETTY_DEBUG=true; shift ;;
|
|
78
|
+ -l) lshandlers; exit ;;
|
77
|
79
|
-V|--version-semver) show_semversion ;;
|
78
|
80
|
--version) show_version ;;
|
79
|
81
|
-*) usage -w "unknown argument: '$1'" ;;
|
80
|
82
|
*) break ;;
|
81
|
83
|
esac done
|
82
|
84
|
Action="$1"; shift
|
83
|
|
- grep -qw "$Action" <<< "newmail|rewind|cleanup|migrate" \
|
84
|
|
- || usage -w "invalid action: $Action"
|
|
85
|
+ lshandlers | grep -qw "$Action" \
|
|
86
|
+ || dle "no handler for action: $Action.lua in $IMAPDOMO_HOME/handlers"
|
85
|
87
|
cmd=$(mkcmd)
|
86
|
88
|
debug -v cmd
|
87
|
89
|
bash -n <<<"$cmd" || die
|