Check-in [3bc708ba71]
Overview
Comment:More options for the API client
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3bc708ba71e6ba0d552b235ba0b75aaf579abbf7
User & Date: rkeene on 2019-02-28 09:48:58
Other Links: manifest | tags
Context
2019-02-28
10:19
More better API check-in: f8c7c20a57 user: rkeene tags: trunk
09:48
More options for the API client check-in: 3bc708ba71 user: rkeene tags: trunk
09:28
Slightly more safety check-in: ff41f3e354 user: rkeene tags: trunk
Changes

Modified build/utils/download-api-client from [fe769d0473] to [172cc868bc].

     5      5   
     6      6   # Set arguments
     7      7   declare -A jsonArgs
     8      8   jsonArgs["platform"]="$(uname -s)-$(uname -m)"
     9      9   
    10     10   nextArg=''
    11     11   kit_filename=''
           12  +options=()
    12     13   for arg in "$@"; do
    13     14   	if [ -n "${nextArg}" ]; then
    14     15   		jsonArgs["${nextArg}"]="${arg}"
    15     16   		nextArg=''
    16     17   		continue
    17     18   	fi
    18     19   
    19     20   	case "${arg}" in
    20     21   		--platform|--tcl-version|--kitcreator-version)
    21     22   			nextArg="${arg:2}"
    22     23   			nextArg="${nextArg//-/_}"
    23     24   			;;
           25  +		--kitdll|--threaded)
           26  +			options+=("${arg:2}")
           27  +			;;
    24     28   	esac
    25     29   done
           30  +
           31  +if [ -n "${options[*]}" ]; then
           32  +	jsonArgs["options"]="${options[@]}"
           33  +fi
    26     34   
    27     35   # Convert arguments into a request
    28     36   jqArgs=()
    29     37   jqSettings=''
    30     38   for jsonArg in "${!jsonArgs[@]}"; do
    31         -	jqArgs+=(--arg "${jsonArg}" "${jsonArgs[${jsonArg}]}")
           39  +	case "${jsonArg}" in
           40  +		options)
           41  +			requestArray='[]'
           42  +			for value in ${jsonArgs[${jsonArg}]}; do
           43  +				requestArray="$(jq -crM --arg value "${value}" '. + [ $value ]' <<<"${requestArray}")"
           44  +			done
           45  +			jqArgs+=(--argjson "${jsonArg}" "${requestArray}")
           46  +			;;
           47  +		*)
           48  +			jqArgs+=(--arg "${jsonArg}" "${jsonArgs[${jsonArg}]}")
           49  +			;;
           50  +	esac
           51  +
    32     52   	jqSettings="${jqSettings} | .${jsonArg} = \$${jsonArg}"
    33     53   done
    34     54   jqArgs+=("${jqSettings:3}")
    35     55   
    36     56   jsonRequest="$(jq -crM "${jqArgs[@]}" <<<'{"action":"build"}')"
    37     57   
    38     58   # Make the request
................................................................................
    41     61   while true; do
    42     62   	info="$(curl -sSL "${url}")"
    43     63   	terminal="$(jq -crM .terminal <<<"${info}")"
    44     64   
    45     65   	if [ "${terminal}" = 'true' ]; then
    46     66   		break
    47     67   	fi
           68  +
           69  +	if [ -z "${buildStatusWroteHeader}" ]; then
           70  +		buildStatusWroteHeader='1'
           71  +		echo -n 'Building...'
           72  +	fi
    48     73   
    49     74   	sleep 30
    50         -done
    51     75   
           76  +	echo -n '.'
           77  +done
    52     78   status="$(jq -crM .status <<<"${info}")"
           79  +
           80  +if [ -n "${buildStatusWroteHeader}" ]; then
           81  +	echo " ${status}"
           82  +fi
           83  +
    53     84   if [ "${status}" != "complete" ]; then
    54     85   	echo "failed: ${status}" >&2
    55     86   
    56     87   	exit 1
    57     88   fi
    58     89   
    59     90   kit_url="$(jq -crM .kit_url <<<"${info}")"