diff --git a/orcli b/orcli index ce3b780..89b44e2 100755 --- a/orcli +++ b/orcli @@ -76,6 +76,7 @@ orcli_usage() { printf " orcli info \"duplicates\"\n" printf " orcli export tsv \"duplicates\"\n" printf " orcli export tsv \"duplicates\" --output \"duplicates.tsv\"\n" + printf " orcli run --interactive\n" printf " orcli run << EOF\n orcli import csv \"https://git.io/fj5hF\" --projectName \"duplicates\"\n orcli info \"duplicates\"\n orcli export tsv \"duplicates\"\n EOF\n" echo @@ -420,8 +421,8 @@ orcli_run_usage() { echo # :flag.usage - echo " --debug" - printf " do not exit on error and keep shell open\n" + echo " --interactive" + printf " do not exit on error and keep bash shell open\n" echo # :command.usage_args @@ -435,9 +436,10 @@ orcli_run_usage() { # :command.usage_examples printf "Examples:\n" + printf " orcli run --interactive\n" printf " orcli run << EOF\n orcli import csv \"https://git.io/fj5hF\" --projectName \"duplicates\"\n orcli info \"duplicates\"\n orcli export tsv \"duplicates\"\n EOF\n" printf " orcli run --memory \"2000M\" --port \"3334\" << EOF\n orcli import csv \"https://git.io/fj5hF\" --projectName \"duplicates\" &\n orcli import csv \"https://git.io/fj5hF\" --projectName \"copy\" &\n wait\n echo \"finished import\"\n orcli export csv \"duplicates\" --output duplicates.csv &\n orcli export tsv \"duplicates\" --output duplicates.tsv &\n wait\n wc duplicates*\n EOF\n" - printf " orcli run \"file1.sh\" \"file2.sh\" - << EOF\n echo \"finished in \$SECONDS seconds\"\n EOF\n" + printf " orcli run --interactive \"file1.sh\" \"file2.sh\" - << EOF\n echo \"finished in \$SECONDS seconds\"\n EOF\n" echo fi @@ -711,7 +713,7 @@ send_completions() { echo $' ;;' echo $'' echo $' \'run\'*)' - echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_orcli_completions_filter "--debug --help --memory --port -h")" -- "$cur" )' + echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_orcli_completions_filter "--help --interactive --memory --port -h")" -- "$cur" )' echo $' ;;' echo $'' echo $' *)' @@ -847,6 +849,16 @@ 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 + fi + fi + fi + # update OPENREFINE_URL env OPENREFINE_URL="http://localhost:${args[--port]}" @@ -889,9 +901,9 @@ orcli_run_command() { # execute script(s) in subshell export orcli tmpdir OPENREFINE_URL openrefine_pid - # case 1: interactive mode if stdin is selected but not present if [[ ${args[file]} == '-' || ${args[file]} == '"-"' ]]; then if ! read -u 0 -t 0; then + # case 1: interactive mode if stdin is selected but not present bash --rcfile <( cat ~/.bashrc interactive @@ -899,8 +911,8 @@ orcli_run_command() { exit fi fi - # case 2: execute scripts and keep shell running - if [[ ${args[--debug]} ]]; then + if [[ ${args[--interactive]} ]]; then + # case 2: execute scripts and keep shell running bash --rcfile <( cat ~/.bashrc for i in "${!files[@]}"; do @@ -909,13 +921,13 @@ orcli_run_command() { done interactive ) -i