change bin/jval-wrapper.sh to have default pattern

With only 1 arg, `bin/jval-wrapper.sh` will print all JSON values found.

Changed `bin/jval-wrapper.sh` VERSION from "1.0 2024-08-05"
to "1.0.1 2024-08-05".
This commit is contained in:
Landon Curt Noll committed 2024-08-05 01:53:14 -07:00
1 parent 4bb575f482
commit 31d4f9d302
1 file changed
+13 -11
+13 -11
View File
@@ -103,7 +103,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an
# set variables referenced in the usage message # set variables referenced in the usage message
# #
export VERSION="1.0 2024-08-05" export VERSION="1.0.1 2024-08-05"
NAME=$(basename "$0") NAME=$(basename "$0")
export NAME export NAME
export V_FLAG=0 export V_FLAG=0
@@ -147,6 +147,7 @@ if ! "$JSONPATH_SH" -S -A -T -p >/dev/null 2>&1; then
exit 5 exit 5
fi <<< "$FIZZBIN_JSON" fi <<< "$FIZZBIN_JSON"
export JSONPATH_ARG export JSONPATH_ARG
export PATTERN='$*'
# #
unset OPTION unset OPTION
declare -ag OPTION declare -ag OPTION
@@ -155,7 +156,7 @@ declare -ag OPTION
# #
export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N]
[-w] [-b] [-i] [-w] [-b] [-i]
[-j JSONPath.sh] file.json pattern [-j JSONPath.sh] file.json [pattern]
-h print help message and exit -h print help message and exit
-v level set verbosity level (def level: 0) -v level set verbosity level (def level: 0)
@@ -171,7 +172,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N]
-j JSONPath.sh path to the JSONPath.sh tool (not the wrapper) (def: $JSONPATH_SH) -j JSONPath.sh path to the JSONPath.sh tool (not the wrapper) (def: $JSONPATH_SH)
file.json JSON file to read, - ==> read stdin file.json JSON file to read, - ==> read stdin
pattern The JSONPath query pattern JSONPath query (def: $PATTERN}
Exit codes: Exit codes:
0 all OK 0 all OK
@@ -243,16 +244,17 @@ shift $(( OPTIND - 1 ));
if [[ $V_FLAG -ge 1 ]]; then if [[ $V_FLAG -ge 1 ]]; then
echo "$0: debug[5]: argument count: $#" 1>&2 echo "$0: debug[5]: argument count: $#" 1>&2
fi fi
if [[ $# -ne 2 ]]; then case "$#" in
echo "$0: ERROR: expected 2 args, found: $#" 1>&2 1) JSON_FILE="$1"
;;
2) JSON_FILE="$1"
PATTERN="$2"
;;
*) echo "$0: ERROR: expected i or 2 args, found: $#" 1>&2
echo "$USAGE" 1>&2 echo "$USAGE" 1>&2
exit 3 exit 3
fi ;;
export JSON_FILE="$1" esac
if [[ $JSON_FILE = - ]]; then
JSON_FILE=""
fi
export PATTERN="$2"
# #
if [[ -n $JSON_FILE ]]; then if [[ -n $JSON_FILE ]]; then
if [[ ! -e $JSON_FILE ]]; then if [[ ! -e $JSON_FILE ]]; then