From 6991b71ccb8f5f9cea66ad2a3c84ad07acf73793 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 24 May 2018 16:51:23 +1000 Subject: [PATCH] general: Added json output option. --- neofetch | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/neofetch b/neofetch index bd09a0b7..0b3bf650 100755 --- a/neofetch +++ b/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