Add `_jsonstr` helper for JSON one-line strings
This commit is contained in:
parent
55f60d849f
commit
65cd8eb81c
|
@ -90,6 +90,12 @@ to `$PAGER` (default: more).
|
||||||
|
|
||||||
Also see `readme` and `usage` commands.
|
Also see `readme` and `usage` commands.
|
||||||
|
|
||||||
|
### The `json` Command
|
||||||
|
|
||||||
|
Converts input into JSON string using `jq` containing only escaped
|
||||||
|
(`
|
||||||
|
`) line returns.
|
||||||
|
|
||||||
### Generate `README.md` File
|
### Generate `README.md` File
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -106,5 +112,5 @@ Displays a summary of usage.
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
*Autogenerated Tue Aug 10 07:37:40 PM EDT 2021*
|
*Autogenerated Tue Aug 10 09:32:13 PM EDT 2021*
|
||||||
|
|
||||||
|
|
14
command
14
command
|
@ -96,6 +96,14 @@ command_bar() {
|
||||||
echo "would bar: $*"
|
echo "would bar: $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
help[json]='
|
||||||
|
Converts input into JSON string using `jq` containing only escaped
|
||||||
|
(`\n`) line returns.'
|
||||||
|
|
||||||
|
command_json() {
|
||||||
|
_jsonstr "$@"
|
||||||
|
}
|
||||||
|
|
||||||
command__hidden() {
|
command__hidden() {
|
||||||
_filter "$@" && return $?
|
_filter "$@" && return $?
|
||||||
echo "would run _hidden: $*"
|
echo "would run _hidden: $*"
|
||||||
|
@ -186,7 +194,6 @@ command_readme() {
|
||||||
echo -e "----\n\n*Autogenerated $(date)*\n"
|
echo -e "----\n\n*Autogenerated $(date)*\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_help_title() {
|
_help_title() {
|
||||||
_filter "$@" && return $?;
|
_filter "$@" && return $?;
|
||||||
local name="$1"
|
local name="$1"
|
||||||
|
@ -202,6 +209,11 @@ _trim() {
|
||||||
echo -e "${it%"${it##*[![:space:]]}"}"
|
echo -e "${it%"${it##*[![:space:]]}"}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_jsonstr() {
|
||||||
|
_buffer "$@" && return $?
|
||||||
|
jq -MRsc <<< "$1"
|
||||||
|
}
|
||||||
|
|
||||||
_have(){ type "$1" &>/dev/null; }
|
_have(){ type "$1" &>/dev/null; }
|
||||||
|
|
||||||
_filter(){
|
_filter(){
|
||||||
|
|
Loading…
Reference in New Issue