Skip to content

Commit

Permalink
style: update ziextract log messages prefix (#411)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
  • Loading branch information
vladdoster authored Nov 5, 2022
1 parent f4787dc commit fcd2aa6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
2 changes: 1 addition & 1 deletion doc/zsdoc/zinit-install.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ ____
$2 - file
____
Has 297 line(s). Calls functions:
Has 283 line(s). Calls functions:
ziextract
`-- zinit.zsh/+zinit-message
Expand Down
43 changes: 14 additions & 29 deletions zinit-install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ ziextract() {
local -a opt_move opt_move2 opt_norm opt_auto opt_nobkp
zparseopts -D -E -move=opt_move -move2=opt_move2 -norm=opt_norm \
-auto=opt_auto -nobkp=opt_nobkp || \
{ +zinit-message "{error}ziextract:{msg2} Incorrect options given to" \
{ +zinit-message "{info}[{pre}ziextract{info}]{error} Incorrect options given to" \
"\`{pre}ziextract{msg2}' (available are: {meta}--auto{msg2}," \
"{meta}--move{msg2}, {meta}--move2{msg2}, {meta}--norm{msg2}," \
"{meta}--nobkp{msg2}).{rst}"; return 1; }
Expand Down Expand Up @@ -1671,9 +1671,7 @@ ziextract() {
type=${(L)desc/(#b)(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) */$match[2]}
if [[ $type = (zip|rar|xz|7-zip|gzip|bzip2|tar|exe|pe32) ]] {
(( !OPTS[opt_-q,--quiet] )) && \
+zinit-message "{pre}ziextract:{info2} Note:{rst}" \
"detected a {meta}$type{rst} archive in the file" \
"{file}$fname{rst}."
+zinit-message "{info}[{pre}ziextract{info}]{msg2} detected a {meta}$type{rst} archive in the file {file}$fname{rst}."
ziextract "$fname" "$type" $opt_move $opt_move2 $opt_norm --norm ${${${#archives}:#1}:+--nobkp}
integer iret_val=$?
ret_val+=iret_val
Expand All @@ -1699,9 +1697,7 @@ ziextract() {
# this might delete too soon… However, it's unusual case.
[[ $fname != $infname && $norm -eq 0 ]] && command rm -f "$infname"
(( !OPTS[opt_-q,--quiet] )) && \
+zinit-message "{pre}ziextract:{info2} Note:{rst}" \
"detected a {obj}${type2}{rst} archive in the" \
" file {file}${fname}{rst}."
+zinit-message "{info}[{pre}ziextract{info}]{msg2} detected a {obj}${type2}{rst} archive in the file {file}${fname}{rst}."
ziextract "$fname" "$type2" $opt_move $opt_move2 $opt_norm ${${${#archives}:#1}:+--nobkp}
ret_val+=$?
stage2_processed+=( $fname )
Expand All @@ -1719,13 +1715,11 @@ ziextract() {
}

if [[ -z $file ]] {
+zinit-message "{error}ziextract:{msg2} ERROR:{msg} argument" \
"needed (the file to extract) or the {meta}--auto{msg} option."
+zinit-message "{info}[{pre}ziextract{info}]{error} argument needed (the file to extract) or the {meta}--auto{msg} option."
return 1
}
if [[ ! -e $file ]] {
+zinit-message "{error}ziextract:{msg2} ERROR:{msg}" \
"the file \`{meta}${file}{msg}' doesn't exist.{rst}"
+zinit-message "{info}[{pre}ziextract{info}]{error} ERROR:{msg} the file \`{meta}${file}{msg}' doesn't exist.{rst}"
return 1
}
if (( !nobkp )) {
Expand All @@ -1737,7 +1731,7 @@ ziextract() {
.zinit-extract-wrapper() {
local file="$1" fun="$2" retval
(( !OPTS[opt_-q,--quiet] )) && \
+zinit-message "{pre}ziextract:{msg} Unpacking the files from: \`{obj}$file{msg}'{…}{rst}"
+zinit-message "{info}[{pre}ziextract{info}]{rst} Unpacking the files from: \`{obj}$file{msg}'{…}{rst}"
$fun; retval=$?
if (( retval == 0 )) {
local -a files
Expand All @@ -1748,8 +1742,7 @@ ziextract() {
}

→zinit-check() { (( ${+commands[$1]} )) || \
+zinit-message "{error}ziextract:{msg2} Error:{msg} No command {data}$1{msg}," \
"it is required to unpack {file}$2{rst}."
+zinit-message "{info}[{pre}ziextract{info}]{error} Error:{msg} No command {data}$1{msg}, it is required to unpack {file}$2{rst}."
}

case "${${ext:+.$ext}:-$file}" in
Expand Down Expand Up @@ -1835,8 +1828,7 @@ ziextract() {
command hdiutil detach $attached_vol

if (( retval )) {
+zinit-message "{error}ziextract:{msg2} WARNING:{msg}" \
"problem occurred when attempted to copy the files" \
+zinit-message "{info}[{pre}ziextract{info}]{error} Error:{msg} problem occurred when attempted to copy the files" \
"from the mounted image: \`{obj}${file}{msg}'.{rst}"
}
return $retval
Expand All @@ -1858,8 +1850,7 @@ ziextract() {

if [[ $(typeset -f + →zinit-extract) == "→zinit-extract" ]] {
.zinit-extract-wrapper "$file" →zinit-extract || {
+zinit-message -n "{error}ziextract:{msg2} WARNING:{msg}" \
"extraction of the archive \`{file}${file}{msg}' had problems"
+zinit-message -n "{info}[{pre}ziextract{info}]{error} Error:{msg} extraction of the archive \`{file}${file}{msg}' had problems"
local -a bfiles
bfiles=( ._backup/*(DN) )
if (( ${#bfiles} && !nobkp )) {
Expand Down Expand Up @@ -1889,33 +1880,27 @@ ziextract() {
command chmod a+x "${execs[@]}"
if (( !OPTS[opt_-q,--quiet] )) {
if (( ${#execs} == 1 )); then
+zinit-message "{pre}ziextract:{rst}" \
"Successfully extracted and assigned +x chmod to the file:" \
"\`{obj}${execs[1]}{rst}'."
+zinit-message "{info}[{pre}ziextract{info}]{rst} Successfully extracted and assigned +x chmod to the file: {obj}${execs[1]}{rst}."
else
local sep="$ZINIT[col-rst],$ZINIT[col-obj] "
if (( ${#execs} > 7 )) {
+zinit-message "{pre}ziextract:{rst} Successfully" \
+zinit-message "{info}[{pre}ziextract{info}]{rst} Successfully" \
"extracted and marked executable the appropriate files" \
"({obj}${(pj:$sep:)${(@)execs[1,5]:t}},…{rst}) contained" \
"in \`{file}$file{rst}'. All the extracted" \
"{obj}${#execs}{rst} executables are" \
"available in the {msg2}INSTALLED_EXECS{rst}" \
"array."
} else {
+zinit-message "{pre}ziextract:{rst} Successfully" \
"extracted and marked executable the appropriate files" \
+zinit-message "{info}[{pre}ziextract{info}]{rst} Successfully" \
"extracted and marked {obj}${#execs}{rst} executable the appropriate files" \
"({obj}${(pj:$sep:)${execs[@]:t}}{rst}) contained" \
"in \`{file}$file{rst}'."
}
fi
}
} elif (( warning )) {
+zinit-message "{pre}ziextract:" \
"{error}WARNING: {msg}didn't recognize the archive" \
"type of \`{obj}${file}{msg}'" \
"${ext:+/ {obj2}${ext}{msg} }"\
"(no extraction has been done).%f%b"
+zinit-message "{info}[{pre}ziextract{info}]{error} Error:{msg} didn't recognize archive type of {obj}${file}{msg} ${ext:+/ {obj2}${ext}{msg} } (no extraction has been done).{rst}"
}

if (( move | move2 )) {
Expand Down

0 comments on commit fcd2aa6

Please # to comment.