This repository has been archived by the owner on Feb 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslacker.sh
executable file
·78 lines (62 loc) · 1.56 KB
/
slacker.sh
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
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
#
# slacker
#
# copyright (c) 2017Cj_bc
#
# This software is released under MIT License.
# http://opensource.org/license/mit-license.php
# SlackerPath=. # for debug
# version 0.1.3.3
# source textfiles,functions
Version=0.1.3.3
HOMEBREW_PREFIX=`brew --prefix`
shopt -s xpg_echo
if [ "$1" = '--local' ] # just to make debug easier. for changing added before new version
then
SlackerPath=. # for debug
shift
#echo "debug: args after --local shift -> ";echo $@;echo "(at slacker,line18)\n" # debugcode
else
SlackerPath=$HOMEBREW_PREFIX/Cellar/slacker/$Version
fi
source $SlackerPath/.sourcefiles
# Check debug mode
if [ "$1" = '--debug' ]
then
DebugFlag=1 # Set to 1 when is debugmode
shift
fi
# test wheather initialization is in need
if [ "$1" = "init" ] || ! [ -f $HOMEBREW_PREFIX/Cellar/slacker/.basicconf ]
then
echo "you need to setup your slacker first."
setup first #this is in settingfunc.sh file.
exit 0
fi
# with no arg,show version
if [ $# -eq 0 ]
then
echo "version: ${Version}"
exit 0
fi
# if slacker is called with pipe, send them to selected channel with some texts.
if [ -p /dev/stdin ]
then
send < /dev/stdin
fi
#
# test all arg and call function
# Functions are here:
# settingfunc.sh --- setting
# |- setting_channel
# |- setting_user
# sendfunc.sh --- send
#
case "$1" in
"set" ) shift;settingconf $@;;
"send" | "s" ) shift;send $@;;
"channel" | "c" ) shift;settingconf channel $1;;
"help" | "h" ) man slacker || usage;; # Not ready now
* ) echo "unknown argument." 1>&2;usage;;
esac