Differences From
Artifact [172cc868bc]:
1 1 #! /usr/bin/env bash
2 2
3 3 # Define endpoint
4 4 endpoint_url="https://kitcreator.rkeene.org/kitcreator"
5 +
6 +# Help
7 +function print_help() {
8 + echo 'download-api-client [--platform <platform>] [--tcl-version <version>]'
9 + echo ' [--kitcreator-version <version>] [--kitdll]'
10 + echo ' [--threaded] [--debug] [--dynamictk]'
11 + echo ' [--staticpkgs]'
12 + echo 'download-api-client {--help|--platforms|--tcl-versions|'
13 + echo ' --kitcreator-versions|--packages}'
14 +}
5 15
6 16 # Set arguments
7 17 declare -A jsonArgs
8 18 jsonArgs["platform"]="$(uname -s)-$(uname -m)"
9 19
10 20 nextArg=''
11 21 kit_filename=''
................................................................................
18 28 fi
19 29
20 30 case "${arg}" in
21 31 --platform|--tcl-version|--kitcreator-version)
22 32 nextArg="${arg:2}"
23 33 nextArg="${nextArg//-/_}"
24 34 ;;
25 - --kitdll|--threaded)
35 + --kitdll|--threaded|--debug|--dynamictk|--staticpkgs)
26 36 options+=("${arg:2}")
27 37 ;;
38 + --platforms|--tcl-versions|--kitcreator-versions|--packages|--options)
39 + action="${arg:2}"
40 + action="${action//-/_}"
41 +
42 + formatString='%-20s | %s\n'
43 + printf "${formatString}" Name Description
44 + printf '%s+%s\n' --------------------- ---------------------
45 + curl -sSL -d "json={\"action\":\"${action}\"}" "${endpoint_url}" | jq -crM 'keys[] as $k | "\($k) \(.[$k])"' | while read -r platform description; do
46 + printf "${formatString}" "${platform}" "${description}"
47 + done
48 + exit 0
49 + ;;
50 + --help)
51 + print_help
52 + exit 0
53 + ;;
54 + *)
55 + echo "Invalid option \"${arg}\"" >&2
56 + print_help >&2
57 + exit 1
28 58 esac
29 59 done
30 60
31 61 if [ -n "${options[*]}" ]; then
32 62 jsonArgs["options"]="${options[@]}"
33 63 fi
34 64
................................................................................
72 102 fi
73 103
74 104 sleep 30
75 105
76 106 echo -n '.'
77 107 done
78 108 status="$(jq -crM .status <<<"${info}")"
109 +build_log_url="$(jq -crM .build_log_url <<<"${info}")"
79 110
80 111 if [ -n "${buildStatusWroteHeader}" ]; then
81 112 echo " ${status}"
82 113 fi
83 114
84 115 if [ "${status}" != "complete" ]; then
85 116 echo "failed: ${status}" >&2
117 + curl -sSL "${build_log_url}" >&2
86 118
87 119 exit 1
88 120 fi
89 121
90 122 kit_url="$(jq -crM .kit_url <<<"${info}")"
91 123 if [ -z "${kit_filename}" ]; then
92 124 kit_filename="${kit_url//*\//}"