mirror of
https://github.com/dylanaraps/neofetch.git
synced 2025-12-22 19:49:54 +00:00
general: Added json output option.
This commit is contained in:
16
neofetch
16
neofetch
@@ -3909,6 +3909,11 @@ info() {
|
|||||||
prin() {
|
prin() {
|
||||||
# If $2 doesn't exist we format $1 as info.
|
# If $2 doesn't exist we format $1 as info.
|
||||||
if [[ "$(trim "$1")" && "$2" ]]; then
|
if [[ "$(trim "$1")" && "$2" ]]; then
|
||||||
|
if [[ "$json" ]]; then
|
||||||
|
printf " %b\n" "\"${1}\": \"${2}\","
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
string="${1}${2:+: $2}"
|
string="${1}${2:+: $2}"
|
||||||
else
|
else
|
||||||
string="${2:-$1}"
|
string="${2:-$1}"
|
||||||
@@ -4718,6 +4723,17 @@ get_args() {
|
|||||||
exit 1
|
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")
|
"--travis")
|
||||||
print_info() {
|
print_info() {
|
||||||
info title
|
info title
|
||||||
|
|||||||
Reference in New Issue
Block a user