-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
executable file
·97 lines (79 loc) · 1.96 KB
/
build
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
output_file=kafka-bash-completion
installation_dir=/etc/bash_completion.d
_concat_files() {
echo '# vi:ft=bash'
echo
# Print the license
sed 's/^/# /' LICENSE
# Print the Doc
echo
echo '# This script provides bash autocompletion for the following Kafka commands:'
for f in *.autocomplete; do
echo -e "#\t${f%.autocomplete}"
done
echo -e "\n# The environment variables \n# KAFKA_BOOTSTRAP_SERVER and KAFKA_BROKER_LIST\n# can optionally be set to be used as completion suggestions"
# print the helpers
echo
echo "####################"
echo "# Helper Functions #"
echo "####################"
cat helpers.sh
# print the functions
echo
echo "########################"
echo "# Completion Functions #"
echo "########################"
for f in *.autocomplete; do
#local cmd=${f%.sh.autocomplete}
local cmdsh=${f%.autocomplete}
#local fn="_${cmd//-/_}_complete"
echo -e "\n# Completion for ${f%.autocomplete}"
sed '/#\s*INCLUDE/,/#\s*END_INCLUDE/!d;//d' $f
done
# wire them up
echo
for f in *.autocomplete; do
local cmd=${f%.sh.autocomplete}
local cmdsh=${f%.autocomplete}
local fn="_${cmd//-/_}_complete"
echo "complete -F $fn $cmdsh"
echo "complete -F $fn $cmd"
done
} > $output_file
build() {
_concat_files > $output_file
}
clean() {
rm $output_file
}
install() {
mkdir -p $installation_dir
[[ -f $output_file ]] && {
echo "Copying $output_file to $installation_dir"
cp $output_file $installation_dir
}
}
usage() {
echo "Usage: $0 [--build|--clean|--install|--help]"
}
case ${1:-'-b'} in
--makefile)
_concat_files
;;
-c|--clean)
clean
;;
-h|--help)
usage
;;
-b|--build)
build
;;
-i|--install)
install
;;
*)
usage
;;
esac