make test scripts standalone
This commit is contained in:
parent
aea762f22f
commit
8b2e35ced2
316
orcli
316
orcli
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# This script was generated by bashly 0.8.10 (https://bashly.dannyb.co)
|
# This script was generated by bashly 0.9.0 (https://bashly.dannyb.co)
|
||||||
# Modifying it manually is not recommended
|
# Modifying it manually is not recommended
|
||||||
|
|
||||||
# :wrapper.bash3_bouncer
|
# :wrapper.bash3_bouncer
|
||||||
|
@ -377,7 +377,7 @@ orcli_test_usage() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "Usage:\n"
|
printf "Usage:\n"
|
||||||
printf " orcli test [FILE...]\n"
|
printf " orcli test\n"
|
||||||
printf " orcli test --help | -h\n"
|
printf " orcli test --help | -h\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
@ -390,15 +390,6 @@ orcli_test_usage() {
|
||||||
printf " Show this help\n"
|
printf " Show this help\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :command.usage_args
|
|
||||||
printf "Arguments:\n"
|
|
||||||
|
|
||||||
# :argument.usage
|
|
||||||
echo " FILE..."
|
|
||||||
printf " Path to one or more files\n"
|
|
||||||
printf " Default: tests/*.sh\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +626,7 @@ normalize_input() {
|
||||||
input+=("${BASH_REMATCH[2]}")
|
input+=("${BASH_REMATCH[2]}")
|
||||||
elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
|
elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
|
||||||
flags="${BASH_REMATCH[1]}"
|
flags="${BASH_REMATCH[1]}"
|
||||||
for (( i=0 ; i < ${#flags} ; i++ )); do
|
for ((i = 0; i < ${#flags}; i++)); do
|
||||||
input+=("-${flags:i:1}")
|
input+=("-${flags:i:1}")
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
|
@ -648,14 +639,14 @@ normalize_input() {
|
||||||
# :command.inspect_args
|
# :command.inspect_args
|
||||||
inspect_args() {
|
inspect_args() {
|
||||||
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
||||||
if (( ${#args[@]} )); then
|
if ((${#args[@]})); then
|
||||||
echo args:
|
echo args:
|
||||||
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
|
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
|
||||||
else
|
else
|
||||||
echo args: none
|
echo args: none
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( ${#other_args[@]} )); then
|
if ((${#other_args[@]})); then
|
||||||
echo
|
echo
|
||||||
echo other_args:
|
echo other_args:
|
||||||
echo "- \${other_args[*]} = ${other_args[*]}"
|
echo "- \${other_args[*]} = ${other_args[*]}"
|
||||||
|
@ -1052,16 +1043,12 @@ orcli_test_command() {
|
||||||
# src/test_command.sh
|
# src/test_command.sh
|
||||||
# shellcheck shell=bash disable=SC2154
|
# shellcheck shell=bash disable=SC2154
|
||||||
|
|
||||||
# catch args, convert the space delimited string to an array
|
|
||||||
files=()
|
|
||||||
eval "files=(${args[file]})"
|
|
||||||
|
|
||||||
# check existence of files
|
# check existence of files
|
||||||
for i in "${!files[@]}"; do
|
if ! [[ -f "tests/help.sh" ]]; then
|
||||||
if ! [[ -f "${files[$i]}" ]]; then
|
error "Cannot open test files!"
|
||||||
error "cannot open ${files[$i]} (no such file)!"
|
|
||||||
fi
|
fi
|
||||||
done
|
cd "tests"
|
||||||
|
files=(*.sh)
|
||||||
|
|
||||||
# locate orcli and OpenRefine
|
# locate orcli and OpenRefine
|
||||||
scriptpath=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
scriptpath=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
||||||
|
@ -1100,15 +1087,10 @@ orcli_test_command() {
|
||||||
for i in "${!files[@]}"; do
|
for i in "${!files[@]}"; do
|
||||||
set +e
|
set +e
|
||||||
bash -e <(
|
bash -e <(
|
||||||
# support ./orcli
|
|
||||||
if ! command -v orcli &>/dev/null; then
|
if ! command -v orcli &>/dev/null; then
|
||||||
echo "shopt -s expand_aliases"
|
echo "shopt -s expand_aliases"
|
||||||
echo "alias orcli=${scriptpath}/orcli"
|
echo "alias orcli=${scriptpath}/orcli"
|
||||||
fi
|
fi
|
||||||
# separate subdirectory for each test
|
|
||||||
echo "mkdir -p ${OPENREFINE_TMPDIR}/${files[$i]}"
|
|
||||||
echo "cd ${OPENREFINE_TMPDIR}/${files[$i]} || exit 1"
|
|
||||||
# echo test file
|
|
||||||
awk 1 "${files[$i]}"
|
awk 1 "${files[$i]}"
|
||||||
) &>"$OPENREFINE_TMPDIR/test.log"
|
) &>"$OPENREFINE_TMPDIR/test.log"
|
||||||
results+=(${?})
|
results+=(${?})
|
||||||
|
@ -1379,30 +1361,37 @@ orcli_run_command() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
parse_requirements() {
|
parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--version | -v )
|
--version | -v)
|
||||||
version_command
|
version_command
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_usage
|
orcli_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.environment_variables_filter
|
# :command.environment_variables_filter
|
||||||
# :command.environment_variables_default
|
# :command.environment_variables_default
|
||||||
export OPENREFINE_URL="${OPENREFINE_URL:-http://localhost:3333}"
|
export OPENREFINE_URL="${OPENREFINE_URL:-http://localhost:3333}"
|
||||||
|
|
||||||
# :command.dependencies_filter
|
# :command.dependencies_filter
|
||||||
if ! [[ -x "$(command -v curl)" ]]; then
|
if ! command -v curl >/dev/null 2>&1; then
|
||||||
printf "missing dependency: curl\n" >&2
|
printf "missing dependency: curl\n" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if ! [[ -x "$(command -v jq)" ]]; then
|
|
||||||
|
if ! command -v jq >/dev/null 2>&1; then
|
||||||
printf "missing dependency: jq\n" >&2
|
printf "missing dependency: jq\n" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -1411,59 +1400,59 @@ parse_requirements() {
|
||||||
action=${1:-}
|
action=${1:-}
|
||||||
|
|
||||||
case $action in
|
case $action in
|
||||||
-* )
|
-*)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
completions )
|
completions)
|
||||||
action="completions"
|
action="completions"
|
||||||
shift
|
shift
|
||||||
orcli_completions_parse_requirements "$@"
|
orcli_completions_parse_requirements "$@"
|
||||||
shift $#
|
shift $#
|
||||||
;;
|
;;
|
||||||
|
|
||||||
import )
|
import)
|
||||||
action="import"
|
action="import"
|
||||||
shift
|
shift
|
||||||
orcli_import_parse_requirements "$@"
|
orcli_import_parse_requirements "$@"
|
||||||
shift $#
|
shift $#
|
||||||
;;
|
;;
|
||||||
|
|
||||||
list )
|
list)
|
||||||
action="list"
|
action="list"
|
||||||
shift
|
shift
|
||||||
orcli_list_parse_requirements "$@"
|
orcli_list_parse_requirements "$@"
|
||||||
shift $#
|
shift $#
|
||||||
;;
|
;;
|
||||||
|
|
||||||
info )
|
info)
|
||||||
action="info"
|
action="info"
|
||||||
shift
|
shift
|
||||||
orcli_info_parse_requirements "$@"
|
orcli_info_parse_requirements "$@"
|
||||||
shift $#
|
shift $#
|
||||||
;;
|
;;
|
||||||
|
|
||||||
test )
|
test)
|
||||||
action="test"
|
action="test"
|
||||||
shift
|
shift
|
||||||
orcli_test_parse_requirements "$@"
|
orcli_test_parse_requirements "$@"
|
||||||
shift $#
|
shift $#
|
||||||
;;
|
;;
|
||||||
|
|
||||||
transform )
|
transform)
|
||||||
action="transform"
|
action="transform"
|
||||||
shift
|
shift
|
||||||
orcli_transform_parse_requirements "$@"
|
orcli_transform_parse_requirements "$@"
|
||||||
shift $#
|
shift $#
|
||||||
;;
|
;;
|
||||||
|
|
||||||
export )
|
export)
|
||||||
action="export"
|
action="export"
|
||||||
shift
|
shift
|
||||||
orcli_export_parse_requirements "$@"
|
orcli_export_parse_requirements "$@"
|
||||||
shift $#
|
shift $#
|
||||||
;;
|
;;
|
||||||
|
|
||||||
run )
|
run)
|
||||||
action="run"
|
action="run"
|
||||||
shift
|
shift
|
||||||
orcli_run_parse_requirements "$@"
|
orcli_run_parse_requirements "$@"
|
||||||
|
@ -1471,12 +1460,12 @@ parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :command.command_fallback
|
# :command.command_fallback
|
||||||
"" )
|
"")
|
||||||
orcli_usage >&2
|
orcli_usage >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
printf "invalid command: %s\n" "$action" >&2
|
printf "invalid command: %s\n" "$action" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -1488,12 +1477,12 @@ parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_simple
|
# :command.parse_requirements_case_simple
|
||||||
printf "invalid argument: %s\n" "$key" >&2
|
printf "invalid argument: %s\n" "$key" >&2
|
||||||
|
@ -1509,14 +1498,20 @@ parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_completions_parse_requirements() {
|
orcli_completions_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_completions_usage
|
orcli_completions_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="completions"
|
action="completions"
|
||||||
|
@ -1526,12 +1521,12 @@ orcli_completions_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_simple
|
# :command.parse_requirements_case_simple
|
||||||
printf "invalid argument: %s\n" "$key" >&2
|
printf "invalid argument: %s\n" "$key" >&2
|
||||||
|
@ -1547,30 +1542,36 @@ orcli_completions_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_import_parse_requirements() {
|
orcli_import_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_import_usage
|
orcli_import_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action=${1:-}
|
action=${1:-}
|
||||||
|
|
||||||
case $action in
|
case $action in
|
||||||
-* )
|
-*)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
csv )
|
csv)
|
||||||
action="csv"
|
action="csv"
|
||||||
shift
|
shift
|
||||||
orcli_import_csv_parse_requirements "$@"
|
orcli_import_csv_parse_requirements "$@"
|
||||||
shift $#
|
shift $#
|
||||||
;;
|
;;
|
||||||
|
|
||||||
tsv )
|
tsv)
|
||||||
action="tsv"
|
action="tsv"
|
||||||
shift
|
shift
|
||||||
orcli_import_tsv_parse_requirements "$@"
|
orcli_import_tsv_parse_requirements "$@"
|
||||||
|
@ -1578,12 +1579,12 @@ orcli_import_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :command.command_fallback
|
# :command.command_fallback
|
||||||
"" )
|
"")
|
||||||
orcli_import_usage >&2
|
orcli_import_usage >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
printf "invalid command: %s\n" "$action" >&2
|
printf "invalid command: %s\n" "$action" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -1595,12 +1596,12 @@ orcli_import_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_simple
|
# :command.parse_requirements_case_simple
|
||||||
printf "invalid argument: %s\n" "$key" >&2
|
printf "invalid argument: %s\n" "$key" >&2
|
||||||
|
@ -1616,14 +1617,20 @@ orcli_import_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_import_csv_parse_requirements() {
|
orcli_import_csv_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_import_csv_usage
|
orcli_import_csv_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="import csv"
|
action="import csv"
|
||||||
|
@ -1633,7 +1640,7 @@ orcli_import_csv_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--separator )
|
--separator)
|
||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
|
@ -1648,7 +1655,7 @@ orcli_import_csv_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--encoding )
|
--encoding)
|
||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
|
@ -1663,7 +1670,7 @@ orcli_import_csv_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--trimStrings )
|
--trimStrings)
|
||||||
|
|
||||||
# :flag.case_no_arg
|
# :flag.case_no_arg
|
||||||
args[--trimStrings]=1
|
args[--trimStrings]=1
|
||||||
|
@ -1671,7 +1678,7 @@ orcli_import_csv_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--projectName )
|
--projectName)
|
||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
|
@ -1686,19 +1693,19 @@ orcli_import_csv_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--quiet | -q )
|
--quiet | -q)
|
||||||
|
|
||||||
# :flag.case_no_arg
|
# :flag.case_no_arg
|
||||||
args[--quiet]=1
|
args[--quiet]=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_repeatable
|
# :command.parse_requirements_case_repeatable
|
||||||
if [[ -z ${args[file]+x} ]]; then
|
if [[ -z ${args[file]+x} ]]; then
|
||||||
|
@ -1724,14 +1731,20 @@ orcli_import_csv_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_import_tsv_parse_requirements() {
|
orcli_import_tsv_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_import_tsv_usage
|
orcli_import_tsv_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="import tsv"
|
action="import tsv"
|
||||||
|
@ -1741,7 +1754,7 @@ orcli_import_tsv_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--encoding )
|
--encoding)
|
||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
|
@ -1756,7 +1769,7 @@ orcli_import_tsv_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--trimStrings )
|
--trimStrings)
|
||||||
|
|
||||||
# :flag.case_no_arg
|
# :flag.case_no_arg
|
||||||
args[--trimStrings]=1
|
args[--trimStrings]=1
|
||||||
|
@ -1764,7 +1777,7 @@ orcli_import_tsv_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--projectName )
|
--projectName)
|
||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
|
@ -1779,19 +1792,19 @@ orcli_import_tsv_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--quiet | -q )
|
--quiet | -q)
|
||||||
|
|
||||||
# :flag.case_no_arg
|
# :flag.case_no_arg
|
||||||
args[--quiet]=1
|
args[--quiet]=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_repeatable
|
# :command.parse_requirements_case_repeatable
|
||||||
if [[ -z ${args[file]+x} ]]; then
|
if [[ -z ${args[file]+x} ]]; then
|
||||||
|
@ -1816,14 +1829,20 @@ orcli_import_tsv_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_list_parse_requirements() {
|
orcli_list_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_list_usage
|
orcli_list_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="list"
|
action="list"
|
||||||
|
@ -1833,12 +1852,12 @@ orcli_list_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_simple
|
# :command.parse_requirements_case_simple
|
||||||
printf "invalid argument: %s\n" "$key" >&2
|
printf "invalid argument: %s\n" "$key" >&2
|
||||||
|
@ -1854,14 +1873,20 @@ orcli_list_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_info_parse_requirements() {
|
orcli_info_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_info_usage
|
orcli_info_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="info"
|
action="info"
|
||||||
|
@ -1871,12 +1896,12 @@ orcli_info_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_simple
|
# :command.parse_requirements_case_simple
|
||||||
if [[ -z ${args[project]+x} ]]; then
|
if [[ -z ${args[project]+x} ]]; then
|
||||||
|
@ -1904,14 +1929,20 @@ orcli_info_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_test_parse_requirements() {
|
orcli_test_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_test_usage
|
orcli_test_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="test"
|
action="test"
|
||||||
|
@ -1921,44 +1952,41 @@ orcli_test_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_repeatable
|
# :command.parse_requirements_case_simple
|
||||||
if [[ -z ${args[file]+x} ]]; then
|
printf "invalid argument: %s\n" "$key" >&2
|
||||||
|
exit 1
|
||||||
args[file]="\"$1\""
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
args[file]="${args[file]} \"$1\""
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# :command.default_assignments
|
|
||||||
[[ -n ${args[file]:-} ]] || args[file]="tests/*.sh"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_transform_parse_requirements() {
|
orcli_transform_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_transform_usage
|
orcli_transform_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="transform"
|
action="transform"
|
||||||
|
@ -1968,19 +1996,19 @@ orcli_transform_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--quiet | -q )
|
--quiet | -q)
|
||||||
|
|
||||||
# :flag.case_no_arg
|
# :flag.case_no_arg
|
||||||
args[--quiet]=1
|
args[--quiet]=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_repeatable
|
# :command.parse_requirements_case_repeatable
|
||||||
if [[ -z ${args[project]+x} ]]; then
|
if [[ -z ${args[project]+x} ]]; then
|
||||||
|
@ -2015,23 +2043,29 @@ orcli_transform_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_export_parse_requirements() {
|
orcli_export_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_export_usage
|
orcli_export_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action=${1:-}
|
action=${1:-}
|
||||||
|
|
||||||
case $action in
|
case $action in
|
||||||
-* )
|
-*)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
tsv )
|
tsv)
|
||||||
action="tsv"
|
action="tsv"
|
||||||
shift
|
shift
|
||||||
orcli_export_tsv_parse_requirements "$@"
|
orcli_export_tsv_parse_requirements "$@"
|
||||||
|
@ -2039,12 +2073,12 @@ orcli_export_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :command.command_fallback
|
# :command.command_fallback
|
||||||
"" )
|
"")
|
||||||
orcli_export_usage >&2
|
orcli_export_usage >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
printf "invalid command: %s\n" "$action" >&2
|
printf "invalid command: %s\n" "$action" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -2056,12 +2090,12 @@ orcli_export_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_simple
|
# :command.parse_requirements_case_simple
|
||||||
printf "invalid argument: %s\n" "$key" >&2
|
printf "invalid argument: %s\n" "$key" >&2
|
||||||
|
@ -2077,14 +2111,20 @@ orcli_export_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_export_tsv_parse_requirements() {
|
orcli_export_tsv_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_export_tsv_usage
|
orcli_export_tsv_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="export tsv"
|
action="export tsv"
|
||||||
|
@ -2094,7 +2134,7 @@ orcli_export_tsv_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--output )
|
--output)
|
||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
|
@ -2109,7 +2149,7 @@ orcli_export_tsv_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--encoding )
|
--encoding)
|
||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
|
@ -2124,19 +2164,19 @@ orcli_export_tsv_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--quiet | -q )
|
--quiet | -q)
|
||||||
|
|
||||||
# :flag.case_no_arg
|
# :flag.case_no_arg
|
||||||
args[--quiet]=1
|
args[--quiet]=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_simple
|
# :command.parse_requirements_case_simple
|
||||||
if [[ -z ${args[project]+x} ]]; then
|
if [[ -z ${args[project]+x} ]]; then
|
||||||
|
@ -2167,14 +2207,20 @@ orcli_export_tsv_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_run_parse_requirements() {
|
orcli_run_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h )
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_run_usage
|
orcli_run_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="run"
|
action="run"
|
||||||
|
@ -2184,7 +2230,7 @@ orcli_run_parse_requirements() {
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--memory )
|
--memory)
|
||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
|
@ -2199,7 +2245,7 @@ orcli_run_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--port )
|
--port)
|
||||||
|
|
||||||
# :flag.case_arg
|
# :flag.case_arg
|
||||||
if [[ -n ${2+x} ]]; then
|
if [[ -n ${2+x} ]]; then
|
||||||
|
@ -2214,7 +2260,7 @@ orcli_run_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--interactive )
|
--interactive)
|
||||||
|
|
||||||
# :flag.case_no_arg
|
# :flag.case_no_arg
|
||||||
args[--interactive]=1
|
args[--interactive]=1
|
||||||
|
@ -2222,19 +2268,19 @@ orcli_run_parse_requirements() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
# :flag.case
|
||||||
--quiet | -q )
|
--quiet | -q)
|
||||||
|
|
||||||
# :flag.case_no_arg
|
# :flag.case_no_arg
|
||||||
args[--quiet]=1
|
args[--quiet]=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-?* )
|
-?*)
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
printf "invalid option: %s\n" "$key" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_repeatable
|
# :command.parse_requirements_case_repeatable
|
||||||
if [[ -z ${args[file]+x} ]]; then
|
if [[ -z ${args[file]+x} ]]; then
|
||||||
|
@ -2279,97 +2325,111 @@ run() {
|
||||||
normalize_input "$@"
|
normalize_input "$@"
|
||||||
parse_requirements "${input[@]}"
|
parse_requirements "${input[@]}"
|
||||||
|
|
||||||
if [[ $action == "completions" ]]; then
|
case "$action" in
|
||||||
|
"completions")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_completions_usage
|
orcli_completions_usage
|
||||||
else
|
else
|
||||||
orcli_completions_command
|
orcli_completions_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "import" ]]; then
|
"import")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_import_usage
|
orcli_import_usage
|
||||||
else
|
else
|
||||||
orcli_import_command
|
orcli_import_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "import csv" ]]; then
|
"import csv")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_import_csv_usage
|
orcli_import_csv_usage
|
||||||
else
|
else
|
||||||
orcli_import_csv_command
|
orcli_import_csv_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "import tsv" ]]; then
|
"import tsv")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_import_tsv_usage
|
orcli_import_tsv_usage
|
||||||
else
|
else
|
||||||
orcli_import_tsv_command
|
orcli_import_tsv_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "list" ]]; then
|
"list")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_list_usage
|
orcli_list_usage
|
||||||
else
|
else
|
||||||
orcli_list_command
|
orcli_list_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "info" ]]; then
|
"info")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_info_usage
|
orcli_info_usage
|
||||||
else
|
else
|
||||||
orcli_info_command
|
orcli_info_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "test" ]]; then
|
"test")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_test_usage
|
orcli_test_usage
|
||||||
else
|
else
|
||||||
orcli_test_command
|
orcli_test_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "transform" ]]; then
|
"transform")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_transform_usage
|
orcli_transform_usage
|
||||||
else
|
else
|
||||||
orcli_transform_command
|
orcli_transform_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "export" ]]; then
|
"export")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_export_usage
|
orcli_export_usage
|
||||||
else
|
else
|
||||||
orcli_export_command
|
orcli_export_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "export tsv" ]]; then
|
"export tsv")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_export_tsv_usage
|
orcli_export_tsv_usage
|
||||||
else
|
else
|
||||||
orcli_export_tsv_command
|
orcli_export_tsv_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "run" ]]; then
|
"run")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_run_usage
|
orcli_run_usage
|
||||||
else
|
else
|
||||||
orcli_run_command
|
orcli_run_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "root" ]]; then
|
"root")
|
||||||
root_command
|
root_command
|
||||||
fi
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize
|
initialize
|
||||||
|
|
|
@ -118,11 +118,6 @@ commands:
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
help: run functional tests on tmp OpenRefine workspace
|
help: run functional tests on tmp OpenRefine workspace
|
||||||
args:
|
|
||||||
- name: file
|
|
||||||
help: Path to one or more files
|
|
||||||
default: "tests/*.sh"
|
|
||||||
repeatable: true
|
|
||||||
|
|
||||||
- name: transform
|
- name: transform
|
||||||
help: apply undo/redo JSON file(s) to an OpenRefine project
|
help: apply undo/redo JSON file(s) to an OpenRefine project
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
# shellcheck shell=bash disable=SC2154
|
# shellcheck shell=bash disable=SC2154
|
||||||
|
|
||||||
# catch args, convert the space delimited string to an array
|
|
||||||
files=()
|
|
||||||
eval "files=(${args[file]})"
|
|
||||||
|
|
||||||
# check existence of files
|
# check existence of files
|
||||||
for i in "${!files[@]}"; do
|
if ! [[ -f "tests/help.sh" ]]; then
|
||||||
if ! [[ -f "${files[$i]}" ]]; then
|
error "Cannot open test files!"
|
||||||
error "cannot open ${files[$i]} (no such file)!"
|
fi
|
||||||
fi
|
cd "tests"
|
||||||
done
|
files=(*.sh)
|
||||||
|
|
||||||
# locate orcli and OpenRefine
|
# locate orcli and OpenRefine
|
||||||
scriptpath=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
scriptpath=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
||||||
|
@ -48,15 +44,10 @@ results=()
|
||||||
for i in "${!files[@]}"; do
|
for i in "${!files[@]}"; do
|
||||||
set +e
|
set +e
|
||||||
bash -e <(
|
bash -e <(
|
||||||
# support ./orcli
|
|
||||||
if ! command -v orcli &>/dev/null; then
|
if ! command -v orcli &>/dev/null; then
|
||||||
echo "shopt -s expand_aliases"
|
echo "shopt -s expand_aliases"
|
||||||
echo "alias orcli=${scriptpath}/orcli"
|
echo "alias orcli=${scriptpath}/orcli"
|
||||||
fi
|
fi
|
||||||
# separate subdirectory for each test
|
|
||||||
echo "mkdir -p ${OPENREFINE_TMPDIR}/${files[$i]}"
|
|
||||||
echo "cd ${OPENREFINE_TMPDIR}/${files[$i]} || exit 1"
|
|
||||||
# echo test file
|
|
||||||
awk 1 "${files[$i]}"
|
awk 1 "${files[$i]}"
|
||||||
) &>"$OPENREFINE_TMPDIR/test.log"
|
) &>"$OPENREFINE_TMPDIR/test.log"
|
||||||
results+=(${?})
|
results+=(${?})
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
a,b,c
|
||||||
|
1,2,3
|
||||||
|
0,0,0
|
||||||
|
$,\,'
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
a b c
|
||||||
|
1 2 3
|
||||||
|
0 0 0
|
||||||
|
$ \ '
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="help"
|
||||||
|
|
||||||
|
# environment
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
|
cd "${tmpdir}" || exit 1
|
||||||
|
|
||||||
|
# assertion
|
||||||
|
cat << "DATA" > "${t}.assert"
|
||||||
|
orcli - OpenRefine command-line interface written in Bash
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# action
|
||||||
|
orcli --help | head -n1 > "${t}.output"
|
||||||
|
|
||||||
|
# test
|
||||||
|
diff -u "${t}.assert" "${t}.output"
|
|
@ -1,23 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="import-csv"
|
||||||
|
|
||||||
# environment
|
# environment
|
||||||
t="$(basename "$(pwd)" .sh)"
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
# data
|
cp data/example.csv "${tmpdir}"/${t}.csv
|
||||||
cat << "DATA" > "${t}.csv"
|
cp data/example.tsv "${tmpdir}"/${t}.assert
|
||||||
a,b,c
|
cd "${tmpdir}" || exit 1
|
||||||
1,2,3
|
|
||||||
0,0,0
|
|
||||||
$,\,'
|
|
||||||
DATA
|
|
||||||
|
|
||||||
# assertion
|
|
||||||
cat << "DATA" > "${t}.assert"
|
|
||||||
a b c
|
|
||||||
1 2 3
|
|
||||||
0 0 0
|
|
||||||
$ \ '
|
|
||||||
DATA
|
|
||||||
|
|
||||||
# action
|
# action
|
||||||
orcli import csv "${t}.csv"
|
orcli import csv "${t}.csv"
|
||||||
|
|
Loading…
Reference in New Issue