Merge pull request #80 from opencultureconsulting:felixlohmeier/run-error-handling-76
check existence of files
This commit is contained in:
commit
46e181f8af
40
orcli
40
orcli
|
@ -638,7 +638,7 @@ function init_import() {
|
|||
data+=("project-file=@-")
|
||||
else
|
||||
if ! path=$(readlink -e "${file}"); then
|
||||
error "file ${file} not found!"
|
||||
error "cannot open ${file} (no such file)!"
|
||||
fi
|
||||
data+=("project-file=@${path}")
|
||||
fi
|
||||
|
@ -899,6 +899,22 @@ orcli_transform_command() {
|
|||
fi
|
||||
done
|
||||
|
||||
# check existence of files and stdin
|
||||
for i in "${!files[@]}"; do
|
||||
if [[ "${files[$i]}" == '-' ]] || [[ "${files[$i]}" == '"-"' ]]; then
|
||||
# exit if stdin is selected but not present
|
||||
if ! read -u 0 -t 0; then
|
||||
orcli_transform_usage
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# exit if file does not exist
|
||||
if ! [[ -f "${files[$i]}" ]]; then
|
||||
error "cannot open ${files[$i]} (no such file)!"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# support multiple files
|
||||
for i in "${!files[@]}"; do
|
||||
# read each operation into one line
|
||||
|
@ -1009,15 +1025,23 @@ orcli_run_command() {
|
|||
files=()
|
||||
eval "files=(${args[file]})"
|
||||
|
||||
# check if stdin is present if selected
|
||||
if ! [[ ${args[--interactive]} ]]; then
|
||||
if [[ ${args[file]} == '-' ]] || [[ ${args[file]} == '"-"' ]]; then
|
||||
if ! read -u 0 -t 0; then
|
||||
orcli_run_usage
|
||||
exit 1
|
||||
# check existence of files and stdin
|
||||
for i in "${!files[@]}"; do
|
||||
if [[ "${files[$i]}" == '-' ]] || [[ "${files[$i]}" == '"-"' ]]; then
|
||||
# exit if stdin is selected but not present
|
||||
if ! [[ ${args[--interactive]} ]]; then
|
||||
if ! read -u 0 -t 0; then
|
||||
orcli_run_usage
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# exit if file does not exist
|
||||
if ! [[ -f "${files[$i]}" ]]; then
|
||||
error "cannot open ${files[$i]} (no such file)!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# assume that quiet flag shall suppress log output generally in batch mode
|
||||
if [[ ${args[--quiet]} ]]; then
|
||||
|
|
|
@ -40,7 +40,7 @@ function init_import() {
|
|||
data+=("project-file=@-")
|
||||
else
|
||||
if ! path=$(readlink -e "${file}"); then
|
||||
error "file ${file} not found!"
|
||||
error "cannot open ${file} (no such file)!"
|
||||
fi
|
||||
data+=("project-file=@${path}")
|
||||
fi
|
||||
|
|
|
@ -4,15 +4,23 @@
|
|||
files=()
|
||||
eval "files=(${args[file]})"
|
||||
|
||||
# check if stdin is present if selected
|
||||
if ! [[ ${args[--interactive]} ]]; then
|
||||
if [[ ${args[file]} == '-' ]] || [[ ${args[file]} == '"-"' ]]; then
|
||||
if ! read -u 0 -t 0; then
|
||||
orcli_run_usage
|
||||
exit 1
|
||||
# check existence of files and stdin
|
||||
for i in "${!files[@]}"; do
|
||||
if [[ "${files[$i]}" == '-' ]] || [[ "${files[$i]}" == '"-"' ]]; then
|
||||
# exit if stdin is selected but not present
|
||||
if ! [[ ${args[--interactive]} ]]; then
|
||||
if ! read -u 0 -t 0; then
|
||||
orcli_run_usage
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# exit if file does not exist
|
||||
if ! [[ -f "${files[$i]}" ]]; then
|
||||
error "cannot open ${files[$i]} (no such file)!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# assume that quiet flag shall suppress log output generally in batch mode
|
||||
if [[ ${args[--quiet]} ]]; then
|
||||
|
|
|
@ -26,6 +26,22 @@ for i in "${!files[@]}"; do
|
|||
fi
|
||||
done
|
||||
|
||||
# check existence of files and stdin
|
||||
for i in "${!files[@]}"; do
|
||||
if [[ "${files[$i]}" == '-' ]] || [[ "${files[$i]}" == '"-"' ]]; then
|
||||
# exit if stdin is selected but not present
|
||||
if ! read -u 0 -t 0; then
|
||||
orcli_transform_usage
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# exit if file does not exist
|
||||
if ! [[ -f "${files[$i]}" ]]; then
|
||||
error "cannot open ${files[$i]} (no such file)!"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# support multiple files
|
||||
for i in "${!files[@]}"; do
|
||||
# read each operation into one line
|
||||
|
|
Loading…
Reference in New Issue