Merge pull request #120 from dylanaraps/separator

Reimplement '--stdout_separator'
This commit is contained in:
Dylan Araps 2016-03-04 07:54:19 +11:00
commit 08118a9375
2 changed files with 27 additions and 2 deletions

View file

@ -321,6 +321,14 @@ scrot_dir="$HOME/Pictures"
scrot_name="neofetch-%Y-%m-%d-%H:%M.png" scrot_name="neofetch-%Y-%m-%d-%H:%M.png"
# }}}
# Stdout options {{{
# Separator for stdout mode
# --stdout_separator string
stdout_separator=" "
# }}} # }}}
# Config Options {{{ # Config Options {{{

View file

@ -342,6 +342,14 @@ scrot_dir="$HOME/Pictures"
scrot_name="neofetch-%Y-%m-%d-%H:%M.png" scrot_name="neofetch-%Y-%m-%d-%H:%M.png"
# }}}
# Stdout options {{{
# Separator for stdout mode
# --stdout_separator string
stdout_separator=" "
# }}} # }}}
# Config Options {{{ # Config Options {{{
@ -1956,16 +1964,25 @@ prin () {
# Stdout {{{ # Stdout {{{
stdout () { stdout () {
# Read args early for the separator
stdout_separator_flag="$(awk -F '--stdout_separator ' '{printf $2}' <<< "${args[@]}")"
stdout_separator_flag=${stdout_separator_flag/ '--'*}
[ ! -z "$stdout_separator_flag" ] && \
stdout_separator="$stdout_separator_flag"
for func in "${args[@]}"; do for func in "${args[@]}"; do
case "$func" in case "$func" in
"--"*) break ;; "--"*) break ;;
*) *)
"get$func" 2>/dev/null "get$func" 2>/dev/null
eval output="\$$func" eval output="\$$func"
printf "%s" "$output " stdout+="${output}${stdout_separator}"
;; ;;
esac esac
done done
printf "%s" "${stdout%%${stdout_separator}}"
exit exit
} }
@ -2448,7 +2465,7 @@ while [ "$1" ]; do
unset info_color colors unset info_color colors
case "$2" in case "$2" in
"--"* | "") echo "--stdout requires at least one argument"; exit ;; "--"* | "") echo "--stdout requires at least one argument"; exit ;;
*) shift; args=("$@"); config="off" stdout ;; *) shift; args=("$@"); config="off"; stdout ;;
esac esac
;; ;;