Add yaml_to_json, json_to_yaml, and k8s_last_config functions
This commit is contained in:
parent
bdf3ee8277
commit
6c25eb7b7d
@ -20,7 +20,7 @@ add_date_prefix () (
|
||||
DATE=$(date -r "$1" +"%F")
|
||||
if [ ! -f "$1" ] ; then
|
||||
echo "unknown file: $1"
|
||||
return
|
||||
exit 1
|
||||
fi
|
||||
mv "$1" "$DIR/${DATE}_${FILE}"
|
||||
)
|
||||
@ -28,11 +28,33 @@ add_date_prefix () (
|
||||
get_bitrate () (
|
||||
if [ ! -f "$1" ] ; then
|
||||
echo "[ERROR] unknown file: $1"
|
||||
return
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v exiftool > /dev/null ; then
|
||||
echo "[ERROR] exiftool not installed"
|
||||
return
|
||||
exit 1
|
||||
fi
|
||||
exiftool -AudioBitrate "$1" | awk '{print $4}'
|
||||
)
|
||||
|
||||
json_to_yaml () (
|
||||
ARG=${1:-}
|
||||
if [ -z "${ARG}" ] ; then
|
||||
dasel --read json --write yaml | bat --language yaml
|
||||
elif [ -f "${ARG}" ] ; then
|
||||
dasel --read json --write yaml --file "${ARG}" | bat --language yaml
|
||||
else
|
||||
echo "${ARG}" | dasel --read json --write yaml | bat --language yaml
|
||||
fi
|
||||
)
|
||||
|
||||
yaml_to_json () (
|
||||
ARG=${1:-}
|
||||
if [ -z "${ARG}" ] ; then
|
||||
dasel --read yaml --write json | bat --language json
|
||||
elif [ -f "${ARG}" ] ; then
|
||||
dasel --read yaml --write json --file "${ARG}" | bat --language json
|
||||
else
|
||||
echo "${ARG}" | dasel --read yaml --write json | bat --language json
|
||||
fi
|
||||
)
|
||||
|
||||
@ -1,5 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
k8s_last_config () (
|
||||
dasel --read yaml --write json \
|
||||
| jq --raw-output '.metadata.annotations["kubectl.kubernetes.io/last-applied-configuration"]' \
|
||||
| dasel --read json --write yaml \
|
||||
| bat --language yaml
|
||||
)
|
||||
|
||||
_add_path () {
|
||||
if [ ! -d "$1" ]; then
|
||||
return
|
||||
|
||||
Loading…
Reference in New Issue
Block a user