1
0
Fork 0
mirror of synced 2024-11-26 17:25:35 -05:00

Warning when no initialization found in a module

Some plugins don't follow the `module_name.plugin.zsh` name, as "it is
the wild west out there".

Fixes #395
This commit is contained in:
Eric Nielsen 2020-05-25 14:01:00 -05:00
parent e73285c4d1
commit c0d786229c
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
4 changed files with 18 additions and 10 deletions

View file

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- "No such file or directory" displayed when building a new file. This was a - "No such file or directory" displayed when building a new file. This was a
regression introduced after replacing `cmp` by `cksum`. regression introduced after replacing `cmp` by `cksum`.
- Show warning message when nothing found to be initialized in a module.
## [1.2.0] - 2020-05-17 ## [1.2.0] - 2020-05-17

View file

@ -30,7 +30,7 @@ Initialization options:
return 1 return 1
fi fi
if (( ! # )); then if (( ! # )); then
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}: Missing zmodule url%f" print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}: Missing zmodule url%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -52,7 +52,7 @@ Initialization options:
shift shift
if [[ ${1} == (-n|--name) ]]; then if [[ ${1} == (-n|--name) ]]; then
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f" print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -65,7 +65,7 @@ Initialization options:
case ${1} in case ${1} in
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source) -b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f" print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -101,7 +101,7 @@ Initialization options:
;; ;;
-d|--disabled) zdisabled=1 ;; -d|--disabled) zdisabled=1 ;;
*) *)
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f" print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 1
;; ;;
@ -130,6 +130,9 @@ Initialization options:
if (( ! ${#zscripts} )); then if (( ! ${#zscripts} )); then
zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
fi fi
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zscripts} )); 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}
fi
_zfpaths+=(${zfpaths}) _zfpaths+=(${zfpaths})
_zfunctions+=(${zfunctions}) _zfunctions+=(${zfunctions})
_zscripts+=(${zscripts}) _zscripts+=(${zscripts})

View file

@ -1,6 +1,6 @@
<% <%
class Zim class Zim
attr_reader :home, :min_zsh_version, :startup_files_glob, :version, :ellipsis, :okay, :error, :done, :failed attr_reader :home, :min_zsh_version, :startup_files_glob, :version, :ellipsis, :okay, :warn, :error, :done, :failed
def initialize def initialize
@home = "${ZDOTDIR:-${HOME}}" @home = "${ZDOTDIR:-${HOME}}"
@ -9,6 +9,7 @@ class Zim
@version = "1.2.1-SNAPSHOT" @version = "1.2.1-SNAPSHOT"
@ellipsis = " ..." @ellipsis = " ..."
@okay = "%F{green})%f " @okay = "%F{green})%f "
@warn = "! "
@error = "x " @error = "x "
@done = "" @done = ""
@failed = "" @failed = ""

View file

@ -132,7 +132,7 @@ Initialization options:
return 1 return 1
fi fi
if (( ! # )); then if (( ! # )); then
print -u2 -PR "%F{red}x ${funcfiletrace[1]}: Missing zmodule url%f" print -u2 -PR "%F{red}x ${funcfiletrace[1]}: Missing zmodule url%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -154,7 +154,7 @@ Initialization options:
shift shift
if [[ ${1} == (-n|--name) ]]; then if [[ ${1} == (-n|--name) ]]; then
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f" print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -167,7 +167,7 @@ Initialization options:
case ${1} in case ${1} in
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source) -b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f" print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 1
fi fi
@ -203,7 +203,7 @@ Initialization options:
;; ;;
-d|--disabled) zdisabled=1 ;; -d|--disabled) zdisabled=1 ;;
*) *)
print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f" print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 1
;; ;;
@ -232,6 +232,9 @@ Initialization options:
if (( ! ${#zscripts} )); then if (( ! ${#zscripts} )); then
zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
fi fi
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zscripts} )); 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}
fi
_zfpaths+=(${zfpaths}) _zfpaths+=(${zfpaths})
_zfunctions+=(${zfunctions}) _zfunctions+=(${zfunctions})
_zscripts+=(${zscripts}) _zscripts+=(${zscripts})
@ -296,7 +299,7 @@ _zimfw_compile() {
} }
_zimfw_info() { _zimfw_info() {
print -R 'zimfw version: '${_zversion}' (previous commit is 853e5a7)' print -R 'zimfw version: '${_zversion}' (previous commit is e73285c)'
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)