-
Notifications
You must be signed in to change notification settings - Fork 17
/
conf
executable file
·51 lines (43 loc) · 1.22 KB
/
conf
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
#!/bin/bash
if [ -z "$COOG_CODE_DIR" ] || [ ! -d "$COOG_CODE_DIR" ] || [ -z "$COOG_DATA_DIR" ]
then
{
echo "Please make sure that these two env vars are set:"
echo " COOG_CODE_DIR: your coog-admin install folder"
echo " COOG_DATA_DIR: the folder where to keep your custom config"
} >&2 && exit 1
fi
_commit() {
config_data_path_changed config \
&& git add config \
&& config_data_commit -m "update config"
}
_edit() {
"$EDITOR" "$COOG_DATA_DIR/config"
( cd "$COOG_DATA_DIR" && _commit )
}
_log() {
( cd "$COOG_DATA_DIR" && git log --graph --abbrev-commit --decorate "$@" )
}
_show() {
( cd "$COOG_DATA_DIR" && git show "$@" )
}
usage() {
echo
echo Available commands
echo
echo " edit -> edits coog data config"
echo " log -> shows coog data history"
echo " show -> shows coog data changeset"
echo
}
main() {
source "$COOG_CODE_DIR/config"
[ -z "$1" ] && usage && return 1
local cmd; cmd=$1; shift
[ "$cmd" = "edit" ] && { _edit "$@"; return $?; }
[ "$cmd" = "log" ] && { _log "$@"; return $?; }
[ "$cmd" = "show" ] && { _show "$@"; return $?; }
echo "bad command" >&2 && return 1
}
main "$@"