4
4
5
5
# @todo test all commands on mac, windows-wsl. If there are issues, rewrite this in (plain, no dependencies) php or make it a polyglot?
6
6
7
+ # download the demo files and unzip them in the 'demo' folder
7
8
function download_demos() {
8
9
# @todo check for presence of curl, tar, grep, sed and tr first
9
10
# NB: we always get the demos matching the current version, not the last one available
@@ -14,12 +15,14 @@ function download_demos() {
14
15
rm demofiles.tgz
15
16
}
16
17
18
+ # remove the 'demo' folder
17
19
function remove_demos() {
18
20
ROOT_DIR=" $( pwd) "
19
21
if [ -d " ${ROOT_DIR} /demo" ]; then rm -rf " ${ROOT_DIR} /demo" ; fi
20
22
}
21
23
22
24
# @todo can we find a better name than this?
25
+ # download and install the visual-editing component into the debugger
23
26
function setup_debugger_visualeditor() {
24
27
ROOT_DIR=" $( pwd) "
25
28
cd " ${TMPDIR-/ tmp} "
@@ -38,11 +41,13 @@ function setup_debugger_visualeditor() {
38
41
rm -rf jsxmlrpc*
39
42
}
40
43
44
+ # remove the visual-editing component from the debugger
41
45
function remove_debugger_visualeditor() {
42
46
ROOT_DIR=" $( pwd) "
43
47
if [ -d " ${ROOT_DIR} /debugger/jsxmlrpc" ]; then rm -rf " ${ROOT_DIR} /debugger/jsxmlrpc" ; fi
44
48
}
45
49
50
+ # arg: $TAG. Replaces the lib version tag in all files (soutrce and docs) known to use it
46
51
function tag_code() {
47
52
TAG=" $1 "
48
53
if [ -z " ${TAG} " ]; then
@@ -56,10 +61,39 @@ function tag_code() {
56
61
sed -i -e " 1s|.*|## XML-RPC for PHP version $TAG - $DATE |" NEWS.md
57
62
}
58
63
64
+ # install the git hooks useful for development of this library
65
+ function setup_git_hooks() {
66
+ if [ -f " $( pwd) /.git/hooks/pre-push" ]; then
67
+ echo " ERROR: git pre-push hook already exists. Please check and remove file $( pwd) /.git/hooks/pre-push" >&2
68
+ exit 1
69
+ else
70
+ ln -s " $( pwd) /.githooks/pre-push.sh" " $( pwd) /.git/hooks/pre-push"
71
+ fi
72
+ }
73
+
74
+ # prints this help text
59
75
function help() {
76
+ # @todo allow a tag such as `# @internal` to denote functions as not available for external execution
77
+ declare -A DESCRIPTIONS
78
+ local CMD MAX LEN
60
79
echo " $0 <task> <args>"
61
80
echo " Tasks:"
62
- compgen -A function | cat -n
81
+ MAX=-1
82
+ for CMD in $( compgen -A function) ; do
83
+ LEN=${# CMD}
84
+ (( LEN > MAX)) && MAX=$LEN
85
+ DESCRIPTIONS[$CMD ]=$( grep " function $CMD (" -B 1 " ${BASH_SOURCE[0]} " | grep ' ^#' | grep -v ' @todo' | sed ' s/^# *//' )
86
+ done
87
+ MAX=$(( MAX + 4 ))
88
+ for CMD in $( compgen -A function) ; do
89
+ if [ -z " ${DESCRIPTIONS[$CMD]} " ]; then
90
+ echo " ${CMD} "
91
+ else
92
+ printf " %-${MAX} s %s\n" " ${CMD} " " ${DESCRIPTIONS[$CMD]} "
93
+ # echo " ${CMD}: ${DESCRIPTIONS[$CMD]}"
94
+ fi
95
+
96
+ done
63
97
}
64
98
65
99
if [ $# -eq 0 ]; then
0 commit comments