2022-11-16 16:37:34 +01:00
|
|
|
# post to export-rows endpoint
|
|
|
|
# shellcheck shell=bash disable=SC2154
|
|
|
|
function post_export() {
|
|
|
|
local curloptions
|
|
|
|
mapfile -t curloptions < <(for d in "$@"; do
|
|
|
|
echo "--data"
|
|
|
|
echo "$d"
|
|
|
|
done)
|
2023-01-12 11:18:06 +01:00
|
|
|
# support file output
|
2022-11-16 16:37:34 +01:00
|
|
|
if [[ ${args[--output]} ]]; then
|
|
|
|
if ! mkdir -p "$(dirname "${args[--output]}")"; then
|
|
|
|
error "unable to create parent directory for ${args[--output]}"
|
|
|
|
fi
|
2023-01-12 11:18:06 +01:00
|
|
|
curloptions+=("--output" "${args[--output]}")
|
2022-11-16 16:37:34 +01:00
|
|
|
fi
|
2023-01-12 11:18:06 +01:00
|
|
|
# post
|
2022-11-16 16:37:34 +01:00
|
|
|
if ! curl -fs "${curloptions[@]}" "${OPENREFINE_URL}/command/core/export-rows"; then
|
|
|
|
error "exporting ${args[project]} failed!"
|
|
|
|
else
|
|
|
|
if [[ ${args[--output]} ]]; then
|
|
|
|
log "exported ${args[project]}" "file: ${args[--output]}" "rows: $(wc -l <"${args[--output]}")"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|