Add options for --stdout

This commit is contained in:
yxnan 2022-10-27 22:16:10 +08:00
parent 23a1b10467
commit 5bf7fbf2b4
No known key found for this signature in database
GPG key ID: 21A68DA4C462D91F

View file

@ -940,11 +940,11 @@ background_color=
# Misc Options # Misc Options
# Stdout mode # Stdout mode
# Turn off all colors and disables image backend (ASCII/Image). # If enabled, turn off all colors and disables image backend (ASCII/Image).
# Useful for piping into another command. # Useful for piping into another command.
# Default: 'off' # Default: 'auto'
# Values: 'on', 'off' # Values: 'auto', 'on', 'off'
stdout="off" stdout="auto"
EOF EOF
# DETECT INFORMATION # DETECT INFORMATION
@ -5960,7 +5960,10 @@ OTHER:
--config none Launch the script without a config file --config none Launch the script without a config file
--no_config Don't create the user config file. --no_config Don't create the user config file.
--print_config Print the default config file to stdout. --print_config Print the default config file to stdout.
--stdout Turn off all colors and disables any ASCII/image backend. --stdout=on Turn off all colors and disables any ASCII/image backend.
--stdout=off Enable the colored output and ASCII/image backend
--stdout=auto Let the program decide basing on the output type (default behavior)
--stdout Equivalent to '--stdout=on', for backward compatibility
--help Print this text and exit --help Print this text and exit
--version Show neofetch version --version Show neofetch version
-v Display error messages. -v Display error messages.
@ -6158,6 +6161,9 @@ get_args() {
;; ;;
"--no_config") no_config="on" ;; "--no_config") no_config="on" ;;
"--stdout") stdout="on" ;; "--stdout") stdout="on" ;;
"--stdout=on") stdout="on" ;;
"--stdout=off") stdout="off" ;;
"--stdout=auto") stdout="auto" ;;
"-v") verbose="on" ;; "-v") verbose="on" ;;
"--print_config") printf '%s\n' "$config"; exit ;; "--print_config") printf '%s\n' "$config"; exit ;;
"-vv") set -x; verbose="on" ;; "-vv") set -x; verbose="on" ;;
@ -13704,7 +13710,10 @@ main() {
get_distro_ascii get_distro_ascii
# check if the output is a interactive terminal # check if the output is a interactive terminal
[[ -t 1 ]] || stdout=on [[ $stdout == auto ]] && {
[[ -t 1 ]] && stdout=off || stdout=on
}
[[ $stdout == on ]] && stdout [[ $stdout == on ]] && stdout
# Minix doesn't support these sequences. # Minix doesn't support these sequences.