Diff

Differences From Artifact [172cc868bc]:

To Artifact [8826872ee9]:


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
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




+
+
+
+
+
+
+
+
+
+




















-
+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#! /usr/bin/env bash

# Define endpoint
endpoint_url="https://kitcreator.rkeene.org/kitcreator"

# Help
function print_help() {
	echo 'download-api-client [--platform <platform>] [--tcl-version <version>]'
	echo '                    [--kitcreator-version <version>] [--kitdll]'
	echo '                    [--threaded] [--debug] [--dynamictk]'
	echo '                    [--staticpkgs]'
	echo 'download-api-client {--help|--platforms|--tcl-versions|'
	echo '                     --kitcreator-versions|--packages}'
}

# Set arguments
declare -A jsonArgs
jsonArgs["platform"]="$(uname -s)-$(uname -m)"

nextArg=''
kit_filename=''
options=()
for arg in "$@"; do
	if [ -n "${nextArg}" ]; then
		jsonArgs["${nextArg}"]="${arg}"
		nextArg=''
		continue
	fi

	case "${arg}" in
		--platform|--tcl-version|--kitcreator-version)
			nextArg="${arg:2}"
			nextArg="${nextArg//-/_}"
			;;
		--kitdll|--threaded)
		--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
			printf '%s+%s\n' --------------------- ---------------------
			curl -sSL -d "json={\"action\":\"${action}\"}" "${endpoint_url}" | jq -crM 'keys[] as $k | "\($k) \(.[$k])"' | while read -r platform description; do
				printf "${formatString}" "${platform}" "${description}"
			done
			exit 0
			;;
		--help)
			print_help
			exit 0
			;;
		*)
			echo "Invalid option \"${arg}\"" >&2
			print_help >&2
			exit 1
	esac
done

if [ -n "${options[*]}" ]; then
	jsonArgs["options"]="${options[@]}"
fi

72
73
74
75
76
77
78

79
80
81
82
83
84
85

86
87
88
89
90
91
92
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124







+







+







	fi

	sleep 30

	echo -n '.'
done
status="$(jq -crM .status <<<"${info}")"
build_log_url="$(jq -crM .build_log_url <<<"${info}")"

if [ -n "${buildStatusWroteHeader}" ]; then
	echo " ${status}"
fi

if [ "${status}" != "complete" ]; then
	echo "failed: ${status}" >&2
	curl -sSL "${build_log_url}" >&2

	exit 1
fi

kit_url="$(jq -crM .kit_url <<<"${info}")"
if [ -z "${kit_filename}" ]; then
	kit_filename="${kit_url//*\//}"