diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-07-13 10:23:35 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-07-13 10:34:03 -0400 |
commit | b8a0d1285c8263bfd94ddc0715b585ce0e1f5cd1 (patch) | |
tree | b27c53cd9297461d2fffac5643bbbe86d9bd06ae | |
parent | 9469d91afdd8ff4a1900e04bf6e1c3a176a31ef0 (diff) | |
download | nexus_bash-b8a0d1285c8263bfd94ddc0715b585ce0e1f5cd1.tar.gz |
Passthrough for persistent verbose
-rw-r--r-- | nexus_bash.sh | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/nexus_bash.sh b/nexus_bash.sh index 79cbc0c..82d135c 100644 --- a/nexus_bash.sh +++ b/nexus_bash.sh @@ -4,7 +4,6 @@ # NEXUS_BASH_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" NEXUS_BASH_INTERFACE_ROOT="${NEXUS_BASH_ROOT}/interface.d" -NEXUS_BASH_VERBOSE=0 # # Global Arguments @@ -20,6 +19,11 @@ NEXUS_URL=${NEXUS_URL:-} # e.g. NEXUS_AUTH="username:password" NEXUS_AUTH=${NEXUS_AUTH:-} +# NEXUS_BASH_VERBOSE: int +# Toggle verbose output mode +# e.g. NEXUS_BASH_VERBOSE=1 +NEXUS_BASH_VERBOSE=${NEXUS_BASH_VERBOSE:-0} + # # Common Functions # @@ -38,3 +42,21 @@ nexus_available() { for iface in $(find "${NEXUS_BASH_INTERFACE_ROOT}" -type f -name '*.sh'); do source "$iface" done + +nexus_json_begin() { + python -c "import json, sys; data=json.load(sys.stdin); $*" +} + +nexus_json_len() { + nexus_json_begin "print(len(data))" +} + +nexus_json_value() { + nexus_json_begin "dict(data[$1]).get('$2', '')" +} + +nexus_json_pairs() { + if (( $# == 1 )); then + nexus_json_begin "[print('{}=\'{}\''.format(k, v)) for (k, v) in dict(data[$1]).items() if k != 'attributes']" + fi +} |