forked from Gentux/imap-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imapcli
executable file
·68 lines (52 loc) · 1.59 KB
/
imapcli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
HELP_MESSAGE="Imap-CLI.
Usage: imapcli [options] <command> [<command_options>...]
Available commands are:
status List unseen, recent and total number of mail per directory in IMAP account
list List mail within a specified directory
search Search for mail
read Display Header and Body of specified mail(s)
flag Set or unset flag on specified mail(s)
copy Copy (or move) mail from one mailbox to another
delete Remove mails (or move to Trash mailbox by default)
Options:
-h, --help Show help options
--version Print program version
See 'imapcli help <command>' to get further information about specified command"
VERSION_MESSAGE="
imap-cli 0.7
Copyright (C) 2014 Romain Soufflet
License MIT
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."
while [[ $# -gt 0 ]]; do
key="$1"
shift
case $key in
status|list|search|read|flag|copy|delete|help)
COMMAND="${key}"
break
;;
-h|--help)
HELP="true"
shift
;;
--version)
VERSION="true"
shift
;;
*)
echo "${HELP_MESSAGE}"
exit 1
;;
esac
done
[ "${HELP}" = "true" ] && echo "${HELP_MESSAGE}" && exit 0
[ "${VERSION}" = "true" ] && echo "${VERSION_MESSAGE}" && exit 0
if [ "${COMMAND}" = "help" ]; then
imap-cli-${1} --help
exit $?
fi
COMMAND="imap-cli-${COMMAND}"
${COMMAND} "$@"
exit $?