Skip to content

Commit

Permalink
bashlib: --overwrite, #476
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Jun 17, 2020
1 parent 574bbad commit 44471a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ocrd/bashlib/src/parse_argv.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ocrd__parse_argv () {
ocrd__raise "Must set \$params (declare -A params)"
fi

ocrd__argv[overwrite]=false

while [[ "${1:-}" = -* ]];do
case "$1" in
-l|--log-level) ocrd__argv[log_level]=$2 ; shift ;;
Expand All @@ -29,6 +31,7 @@ ocrd__parse_argv () {
-I|--input-file-grp) ocrd__argv[input_file_grp]=$2 ; shift ;;
-w|--working-dir) ocrd__argv[working_dir]=$(realpath "$2") ; shift ;;
-m|--mets) ocrd__argv[mets_file]=$(realpath "$2") ; shift ;;
--overwrite) ocrd__argv[overwrite]=true ;;
-V|--version) ocrd ocrd-tool "$OCRD_TOOL_JSON" version; exit ;;
*) ocrd__raise "Unknown option '$1'" ;;
esac
Expand Down
2 changes: 1 addition & 1 deletion ocrd/bashlib/src/wrap.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ocrd__wrap () {
ocrd__raise "Cannot read \$OCRD_TOOL_JSON: '$OCRD_TOOL_JSON'"
fi

if [[ -z "$OCRD_TOOL_NAME" ]];then
if [[ -z "$OCRD_TOOL_NAME" ]];then
ocrd__raise "Must set \$OCRD_TOOL_NAME"
elif ! ocrd ocrd-tool "$OCRD_TOOL_JSON" list-tools|grep -q "$OCRD_TOOL_NAME";then
ocrd__raise "No such command \$OCRD_TOOL_NAME: $OCRD_TOOL_NAME"
Expand Down
5 changes: 4 additions & 1 deletion ocrd/ocrd/lib.bash
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ ocrd__parse_argv () {
ocrd__raise "Must set \$params (declare -A params)"
fi

ocrd__argv[overwrite]=false

while [[ "${1:-}" = -* ]];do
case "$1" in
-l|--log-level) ocrd__argv[log_level]=$2 ; shift ;;
Expand All @@ -117,6 +119,7 @@ ocrd__parse_argv () {
-I|--input-file-grp) ocrd__argv[input_file_grp]=$2 ; shift ;;
-w|--working-dir) ocrd__argv[working_dir]=$(realpath "$2") ; shift ;;
-m|--mets) ocrd__argv[mets_file]=$(realpath "$2") ; shift ;;
--overwrite) ocrd__argv[overwrite]=true ;;
-V|--version) ocrd ocrd-tool "$OCRD_TOOL_JSON" version; exit ;;
*) ocrd__raise "Unknown option '$1'" ;;
esac
Expand Down Expand Up @@ -176,7 +179,7 @@ ocrd__wrap () {
ocrd__raise "Cannot read \$OCRD_TOOL_JSON: '$OCRD_TOOL_JSON'"
fi

if [[ -z "$OCRD_TOOL_NAME" ]];then
if [[ -z "$OCRD_TOOL_NAME" ]];then
ocrd__raise "Must set \$OCRD_TOOL_NAME"
elif ! ocrd ocrd-tool "$OCRD_TOOL_JSON" list-tools|grep -q "$OCRD_TOOL_NAME";then
ocrd__raise "No such command \$OCRD_TOOL_NAME: $OCRD_TOOL_NAME"
Expand Down

0 comments on commit 44471a4

Please sign in to comment.