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
|
# Set arguments
declare -A jsonArgs
jsonArgs["platform"]="$(uname -s)-$(uname -m)"
nextArg=''
kit_filename=''
options=()
internalOptionsVerbose='false'
for arg in "$@"; do
if [ -n "${nextArg}" ]; then
jsonArgs["${nextArg}"]="${arg}"
nextArg=''
continue
fi
case "${arg}" in
--verbose)
internalOptionsVerbose='true'
;;
--platform|--tcl-version|--kitcreator-version)
nextArg="${arg:2}"
nextArg="${nextArg//-/_}"
;;
--kitdll|--threaded|--debug|--dynamictk|--staticpkgs)
options+=("${arg:2}")
;;
--platforms|--tcl-versions|--kitcreator-versions|--packages|--options)
action="${arg:2}"
action="${action//-/_}"
formatString='%-20s | %s\n'
printf "${formatString}" Name Description
|
>
>
>
>
|
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
|
# Set arguments
declare -A jsonArgs
jsonArgs["platform"]="$(uname -s)-$(uname -m)"
nextArg=''
kit_filename=''
options=()
packages=()
internalOptionsVerbose='false'
for arg in "$@"; do
if [ -n "${nextArg}" ]; then
jsonArgs["${nextArg}"]="${arg}"
nextArg=''
continue
fi
case "${arg}" in
--verbose)
internalOptionsVerbose='true'
;;
--platform|--tcl-version|--kitcreator-version)
nextArg="${arg:2}"
nextArg="${nextArg//-/_}"
;;
--kitdll|--threaded|--debug|--dynamictk|--staticpkgs)
options+=("${arg:2}")
;;
--mk4tcl|--tcc4tcl|--tclcurl|--tk|--tls|--tuapi|--itcl|--duktape|--lmdb|--udp)
packages+=("${arg:2}")
;;
--platforms|--tcl-versions|--kitcreator-versions|--packages|--options)
action="${arg:2}"
action="${action//-/_}"
formatString='%-20s | %s\n'
printf "${formatString}" Name Description
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
echo "Invalid option \"${arg}\"" >&2
print_help >&2
exit 1
esac
done
if [ -n "${options[*]}" ]; then
jsonArgs["options"]="${options[@]}"
fi
# Convert arguments into a request
jqArgs=()
jqSettings=''
for jsonArg in "${!jsonArgs[@]}"; do
case "${jsonArg}" in
options)
requestArray='[]'
for value in ${jsonArgs[${jsonArg}]}; do
requestArray="$(jq -crM --arg value "${value}" '. + [ $value ]' <<<"${requestArray}")"
done
jqArgs+=(--argjson "${jsonArg}" "${requestArray}")
;;
*)
|
|
>
>
>
>
|
|
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
|
echo "Invalid option \"${arg}\"" >&2
print_help >&2
exit 1
esac
done
if [ -n "${options[*]}" ]; then
jsonArgs["options"]="${options[*]}"
fi
if [ -n "${packages[*]}" ]; then
jsonArgs["packages"]="${packages[*]}"
fi
# Convert arguments into a request
jqArgs=()
jqSettings=''
for jsonArg in "${!jsonArgs[@]}"; do
case "${jsonArg}" in
options|packages)
requestArray='[]'
for value in ${jsonArgs[${jsonArg}]}; do
requestArray="$(jq -crM --arg value "${value}" '. + [ $value ]' <<<"${requestArray}")"
done
jqArgs+=(--argjson "${jsonArg}" "${requestArray}")
;;
*)
|