From 92e6d6b74b8b47892d897207028a7591ec4c1b70 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Tue, 21 Sep 2021 16:36:32 -0500 Subject: [PATCH] Don't output warnings in quiet mode For sake of simplicity, and also to distinguish warnings from errors. So now we have: * errors: output to stderr, are **not** silenced with `-q` * warnings: output to stderr, are silenced with `-q` * info: output to stdout, are silenced with `-q` * solicited output (like help, info, or list): output to stdout, does not make sense to be silenced with `-q` We also only have warning in 3 situations so far... :- ) --- CHANGELOG.md | 3 +++ src/stage2/30_zmodule.zsh.erb | 4 ++-- src/stage2/80_zimfw.zsh.erb | 2 +- src/tools/degit.zsh.erb | 12 +++++------- zimfw.zsh | 20 +++++++++----------- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bb81fc..3f2b260 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `list` action. Using it with `-v` also shows the current details for all modules. +### Changed +- Be quieter and don't output warnings when `-q` is provided. + ### Fixed - Error in `zimfw update` with the `git` tool when module directory is under a symlinked directory. diff --git a/src/stage2/30_zmodule.zsh.erb b/src/stage2/30_zmodule.zsh.erb index b91b220..ab15e91 100644 --- a/src/stage2/30_zmodule.zsh.erb +++ b/src/stage2/30_zmodule.zsh.erb @@ -89,7 +89,7 @@ Initialization options: esac case ${1} in -b|--branch|-t|--tag|-u|--use) - if [[ -z ${zurl} ]] print -u2 -PR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zmodule}:%b The zmodule option ${1} has no effect for external modules%f" + if [[ -z ${zurl} ]] _zimfw_print -u2 -PR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zmodule}:%b The zmodule option ${1} has no effect for external modules%f" ;; esac case ${1} in @@ -168,7 +168,7 @@ Initialization options: zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t)) fi if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then - print -u2 -PR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f"$'\n\n'${zusage} + _zimfw_print -u2 -PR "%F{yellow}<%= warn %>${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f"$'\n\n'${zusage} fi _zmodules+=(${zmodule}) _zdirs+=(${zdir}) diff --git a/src/stage2/80_zimfw.zsh.erb b/src/stage2/80_zimfw.zsh.erb index 6eab142..606bb2d 100644 --- a/src/stage2/80_zimfw.zsh.erb +++ b/src/stage2/80_zimfw.zsh.erb @@ -18,7 +18,7 @@ Actions: %Bversion%b Print zimfw version. Options: - %B-q%b Quiet (yes to prompts, and only outputs errors and warnings) + %B-q%b Quiet (yes to prompts, and only outputs errors) %B-v%b Verbose (outputs more details)" local -a _zdisableds _zmodules _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs _zunuseds local -i _zprintlevel=1 diff --git a/src/tools/degit.zsh.erb b/src/tools/degit.zsh.erb index 50da9ea..9c04e91 100644 --- a/src/tools/degit.zsh.erb +++ b/src/tools/degit.zsh.erb @@ -9,15 +9,13 @@ print_error() { } print_okay() { - if [[ -e ${DIR}/.gitmodules ]]; then - local -r warn=${CLEAR_LINE}"%F{yellow}<%= warn %>%B${MODULE}:%b ${(C)1}. Module contains git submodules, which are not supported by Zim's degit and were not ${1}.%f" - if (( PRINTLEVEL > 0 )); then - print -PR ${warn}${2:+$'\n'${(F):- ${(f)^2}}} + if (( PRINTLEVEL > 0 )); then + local -r log=${2:+$'\n'${(F):- ${(f)^2}}} + if [[ -e ${DIR}/.gitmodules ]]; then + print -u2 -PR ${CLEAR_LINE}"%F{yellow}<%= warn %>%B${MODULE}:%b ${(C)1}. Module contains git submodules, which are not supported by Zim's degit and were not ${1}.%f"${log} else - print -u2 -PR ${warn} + print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b ${(C)1}"${log} fi - elif (( PRINTLEVEL > 0 )); then - print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b ${(C)1}"${2:+$'\n'${(F):- ${(f)^2}}} fi } diff --git a/zimfw.zsh b/zimfw.zsh index bfcb85c..ab8c34d 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -199,7 +199,7 @@ Initialization options: esac case ${1} in -b|--branch|-t|--tag|-u|--use) - if [[ -z ${zurl} ]] print -u2 -PR "%F{yellow}! ${funcfiletrace[1]}:%B${zmodule}:%b The zmodule option ${1} has no effect for external modules%f" + if [[ -z ${zurl} ]] _zimfw_print -u2 -PR "%F{yellow}! ${funcfiletrace[1]}:%B${zmodule}:%b The zmodule option ${1} has no effect for external modules%f" ;; esac case ${1} in @@ -278,7 +278,7 @@ Initialization options: zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t)) fi if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then - print -u2 -PR "%F{yellow}! ${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f"$'\n\n'${zusage} + _zimfw_print -u2 -PR "%F{yellow}! ${funcfiletrace[1]}:%B${zmodule}:%b Nothing found to be initialized. Customize the module name or initialization with %Bzmodule%b options.%f"$'\n\n'${zusage} fi _zmodules+=(${zmodule}) _zdirs+=(${zdir}) @@ -370,7 +370,7 @@ _zimfw_compile() { } _zimfw_info() { - print -R 'zimfw version: '${_zversion}' (built at 2021-09-21 13:25:55 UTC, previous commit is 7deda9c)' + print -R 'zimfw version: '${_zversion}' (built at 2021-09-21 21:19:43 UTC, previous commit is 9a67adf)' print -R 'ZIM_HOME: '${ZIM_HOME} print -R 'Zsh version: '${ZSH_VERSION} print -R 'System info: '$(command uname -a) @@ -478,15 +478,13 @@ print_error() { } print_okay() { - if [[ -e \${DIR}/.gitmodules ]]; then - local -r warn=\${CLEAR_LINE}\"%F{yellow}! %B\${MODULE}:%b \${(C)1}. Module contains git submodules, which are not supported by Zim's degit and were not \${1}.%f\" - if (( PRINTLEVEL > 0 )); then - print -PR \${warn}\${2:+$'\n'\${(F):- \${(f)^2}}} + if (( PRINTLEVEL > 0 )); then + local -r log=\${2:+$'\n'\${(F):- \${(f)^2}}} + if [[ -e \${DIR}/.gitmodules ]]; then + print -u2 -PR \${CLEAR_LINE}\"%F{yellow}! %B\${MODULE}:%b \${(C)1}. Module contains git submodules, which are not supported by Zim's degit and were not \${1}.%f\"\${log} else - print -u2 -PR \${warn} + print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b \${(C)1}\"\${log} fi - elif (( PRINTLEVEL > 0 )); then - print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b \${(C)1}\"\${2:+$'\n'\${(F):- \${(f)^2}}} fi } @@ -724,7 +722,7 @@ Actions: %Bversion%b Print zimfw version. Options: - %B-q%b Quiet (yes to prompts, and only outputs errors and warnings) + %B-q%b Quiet (yes to prompts, and only outputs errors) %B-v%b Verbose (outputs more details)" local -a _zdisableds _zmodules _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs _zunuseds local -i _zprintlevel=1