general: Added json output option.
This commit is contained in:
parent
14981205c6
commit
6991b71ccb
1 changed files with 16 additions and 0 deletions
16
neofetch
16
neofetch
|
@ -3909,6 +3909,11 @@ info() {
|
|||
prin() {
|
||||
# If $2 doesn't exist we format $1 as info.
|
||||
if [[ "$(trim "$1")" && "$2" ]]; then
|
||||
if [[ "$json" ]]; then
|
||||
printf " %b\n" "\"${1}\": \"${2}\","
|
||||
return
|
||||
fi
|
||||
|
||||
string="${1}${2:+: $2}"
|
||||
else
|
||||
string="${2:-$1}"
|
||||
|
@ -4718,6 +4723,17 @@ get_args() {
|
|||
exit 1
|
||||
;;
|
||||
|
||||
"--json")
|
||||
json="on"
|
||||
unset -f get_title get_cols get_line_break get_underline
|
||||
|
||||
printf "{\n"
|
||||
print_info 2>/dev/null
|
||||
printf " %s\n" "\"Version\": \"${version}\""
|
||||
printf "}\n"
|
||||
exit
|
||||
;;
|
||||
|
||||
"--travis")
|
||||
print_info() {
|
||||
info title
|
||||
|
|
Loading…
Reference in a new issue