-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvite.sh
More file actions
executable file
·53 lines (48 loc) · 1 KB
/
invite.sh
File metadata and controls
executable file
·53 lines (48 loc) · 1 KB
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
#!/bin/bash
function invite() {
curl \
-X POST \
"https://slack.com/api/users.admin.invite?token=${token}&email=${1}"
printf "\n"
}
function usage() {
printf "${usage}"
exit $1 $token
}
usage="$(basename "$0") [-h] [-e email] [-f filename]
Invite members to public Slack community
usage:
-h show this help text
-t Slack legacy token (api.slack.com/custom-integrations/legacy-tokens)
-e invite by email
-f invite multiple emails from file
"
token=""
# TODO: Split while to extract token from any order of flags
while getopts 'ht:e:f:' flag; do
case "${flag}" in
h)
usage
;;
t)
# TODO: Error if missing token
token="${OPTARG}"
;;
e)
printf "Inviting ${OPTARG}: "
invite ${OPTARG}
exit
;;
f)
[[ "`stat ${OPTARG} 2> /dev/null`" == "" ]] && usage 1
while read email; do
printf "Inviting ${email}: "
invite $email
done < ${OPTARG}
exit
;;
*)
usage 1
;;
esac
done