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...  :- )
This commit is contained in:
Eric Nielsen 2021-09-21 16:36:32 -05:00
parent 9a67adfe3b
commit 92e6d6b74b
No known key found for this signature in database
GPG Key ID: 47D1DBFA0765A1FB
5 changed files with 20 additions and 21 deletions

View File

@ -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 - `list` action. Using it with `-v` also shows the current details for all
modules. modules.
### Changed
- Be quieter and don't output warnings when `-q` is provided.
### Fixed ### Fixed
- Error in `zimfw update` with the `git` tool when module directory is under a - Error in `zimfw update` with the `git` tool when module directory is under a
symlinked directory. symlinked directory.

View File

@ -89,7 +89,7 @@ Initialization options:
esac esac
case ${1} in case ${1} in
-b|--branch|-t|--tag|-u|--use) -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 esac
case ${1} in case ${1} in
@ -168,7 +168,7 @@ Initialization options:
zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t)) zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
fi fi
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then 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 fi
_zmodules+=(${zmodule}) _zmodules+=(${zmodule})
_zdirs+=(${zdir}) _zdirs+=(${zdir})

View File

@ -18,7 +18,7 @@ Actions:
%Bversion%b Print zimfw version. %Bversion%b Print zimfw version.
Options: 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)" %B-v%b Verbose (outputs more details)"
local -a _zdisableds _zmodules _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs _zunuseds local -a _zdisableds _zmodules _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs _zunuseds
local -i _zprintlevel=1 local -i _zprintlevel=1

View File

@ -9,15 +9,13 @@ print_error() {
} }
print_okay() { 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 if (( PRINTLEVEL > 0 )); then
print -PR ${warn}${2:+$'\n'${(F):- ${(f)^2}}} 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 else
print -u2 -PR ${warn} print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b ${(C)1}"${log}
fi fi
elif (( PRINTLEVEL > 0 )); then
print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b ${(C)1}"${2:+$'\n'${(F):- ${(f)^2}}}
fi fi
} }

View File

@ -199,7 +199,7 @@ Initialization options:
esac esac
case ${1} in case ${1} in
-b|--branch|-t|--tag|-u|--use) -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 esac
case ${1} in case ${1} in
@ -278,7 +278,7 @@ Initialization options:
zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t)) zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
fi fi
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then 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 fi
_zmodules+=(${zmodule}) _zmodules+=(${zmodule})
_zdirs+=(${zdir}) _zdirs+=(${zdir})
@ -370,7 +370,7 @@ _zimfw_compile() {
} }
_zimfw_info() { _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 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION} print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a) print -R 'System info: '$(command uname -a)
@ -478,15 +478,13 @@ print_error() {
} }
print_okay() { 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 if (( PRINTLEVEL > 0 )); then
print -PR \${warn}\${2:+$'\n'\${(F):- \${(f)^2}}} 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 else
print -u2 -PR \${warn} print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b \${(C)1}\"\${log}
fi fi
elif (( PRINTLEVEL > 0 )); then
print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b \${(C)1}\"\${2:+$'\n'\${(F):- \${(f)^2}}}
fi fi
} }
@ -724,7 +722,7 @@ Actions:
%Bversion%b Print zimfw version. %Bversion%b Print zimfw version.
Options: 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)" %B-v%b Verbose (outputs more details)"
local -a _zdisableds _zmodules _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs _zunuseds local -a _zdisableds _zmodules _zdirs _zfpaths _zfunctions _zcmds _zmodules_zargs _zunuseds
local -i _zprintlevel=1 local -i _zprintlevel=1