orcli/src/export_tsv_command.sh

34 lines
861 B
Bash
Raw Normal View History

2022-04-14 12:06:54 +02:00
# shellcheck shell=bash
projectid="$(get_id "${args[project]}")"
separator='\t'
# assemble specific post data (some options require json format)
data+=("project=${projectid}")
data+=("format=tsv")
options='{ '
options+="\"separator\": \"${separator}\""
if [[ ${args[--encoding]} ]]; then
options+=', '
options+="\"encoding\": \"${args[--encoding]}\""
fi
2023-11-09 15:53:05 +01:00
if [[ ${args[--select]} ]]; then
options+=', '
options+='"columns": ['
IFS=',' read -ra columns <<< "${args[--select]}"
options+='{"name":"'
options+="${columns[0]}"
options+='"}'
for cn in "${columns[@]:1}"; do
options+=', '
options+='{"name":"'
options+="${cn}"
options+='"}'
done
options+="]"
fi
2022-04-14 12:06:54 +02:00
options+=' }'
data+=("options=${options}")
2022-11-16 16:37:34 +01:00
# call post_export function to post data and validate results
post_export "${data[@]}"