mirror of
https://github.com/dylanaraps/neofetch.git
synced 2025-12-15 16:37:13 +00:00
general: Added json output option.
This commit is contained in:
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
|
||||
|
||||
Reference in New Issue
Block a user