feat(version): add verbose option to display up-to-date versions

Sometimes it can be desired to get a results for each entry even if the
current version is up-to-date. Add a --verbose option to print this
optional detail.

Component: pkgctl version check
Component: pkgctl version upgrade
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
Levente Polyak 2024-01-18 03:33:13 +01:00
parent 08ece1640b
commit b258bb3b7c
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
6 changed files with 52 additions and 4 deletions

View File

@ -343,12 +343,14 @@ _pkgctl_version_cmds=(
)
_pkgctl_version_check_args=(
-v --verbose
-h --help
)
_pkgctl_version_check_opts() { _filedir -d; }
_pkgctl_version_upgrade_args=(
-v --verbose
-h --help
)

View File

@ -292,11 +292,13 @@ _pkgctl_version_cmds=(
)
_pkgctl_version_check_args=(
'(-v --verbose)'{-v,--verbose}'[Display results including up-to-date versions]'
'(-h --help)'{-h,--help}'[Display usage]'
'*:git_dir:_files -/'
)
_pkgctl_version_upgrade_args=(
'(-v --verbose)'{-v,--verbose}'[Display results including up-to-date versions]'
'(-h --help)'{-h,--help}'[Display usage]'
'*:git_dir:_files -/'
)

View File

@ -30,6 +30,9 @@ which can be utilized in .nvchecker.toml.
Options
-------
*-v, --verbose*::
Display results including up-to-date versions
*-h, --help*::
Show a help text

View File

@ -22,6 +22,9 @@ The current working directory is used if no PKGBASE is specified.
Options
-------
*-v, --verbose*::
Display results including up-to-date versions
*-h, --help*::
Show a help text

View File

@ -29,7 +29,8 @@ pkgctl_version_check_usage() {
will be supplied from \${XDG_CONFIG_HOME}/nvchecker.
OPTIONS
-h, --help Show this help text
-v, --verbose Display results including up-to-date versions
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} neovim vim
@ -37,9 +38,10 @@ _EOF_
}
pkgctl_version_check() {
local path
local pkgbases=()
local status_file path pkgbase upstream_version result
local verbose=0
local path status_file path pkgbase upstream_version result
local up_to_date=()
local out_of_date=()
@ -53,6 +55,10 @@ pkgctl_version_check() {
pkgctl_version_check_usage
exit 0
;;
-v|--verbose)
verbose=1
shift
;;
--)
shift
break
@ -81,6 +87,11 @@ pkgctl_version_check() {
fi
fi
# enable verbose mode when we only have a single item to check
if (( ${#pkgbases[@]} == 1 )); then
verbose=1
fi
# start a terminal spinner as checking versions takes time
status_dir=$(mktemp --tmpdir="${WORKDIR}" --directory pkgctl-version-check-spinner.XXXXXXXXXX)
term_spinner_start "${status_dir}"
@ -140,6 +151,14 @@ pkgctl_version_check() {
# stop the terminal spinner after all checks
term_spinner_stop "${status_dir}"
if (( verbose )) && (( ${#up_to_date[@]} > 0 )); then
printf "%sUp-to-date%s\n" "${section_separator}${BOLD}${UNDERLINE}" "${ALL_OFF}"
section_separator=$'\n'
for result in "${up_to_date[@]}"; do
msg_success " ${result}"
done
fi
if (( ${#failure[@]} > 0 )); then
printf "%sFailure%s\n" "${section_separator}${BOLD}${UNDERLINE}" "${ALL_OFF}"
section_separator=$'\n'

View File

@ -32,7 +32,8 @@ pkgctl_version_upgrade_usage() {
The current working directory is used if no PKGBASE is specified.
OPTIONS
-h, --help Show this help text
-v, --verbose Display results including up-to-date versions
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} neovim vim
@ -42,6 +43,7 @@ _EOF_
pkgctl_version_upgrade() {
local path upstream_version result
local pkgbases=()
local verbose=0
local exit_code=0
local current_item=0
@ -51,6 +53,10 @@ pkgctl_version_upgrade() {
pkgctl_version_upgrade_usage
exit 0
;;
-v|--verbose)
verbose=1
shift
;;
--)
shift
break
@ -79,6 +85,11 @@ pkgctl_version_upgrade() {
fi
fi
# enable verbose mode when we only have a single item to check
if (( ${#pkgbases[@]} == 1 )); then
verbose=1
fi
# start a terminal spinner as checking versions takes time
status_dir=$(mktemp --tmpdir="${WORKDIR}" --directory pkgctl-version-check-spinner.XXXXXXXXXX)
term_spinner_start "${status_dir}"
@ -142,6 +153,14 @@ pkgctl_version_upgrade() {
# stop the terminal spinner after all checks
term_spinner_stop "${status_dir}"
if (( verbose )) && (( ${#up_to_date[@]} > 0 )); then
printf "%sUp-to-date%s\n" "${section_separator}${BOLD}${UNDERLINE}" "${ALL_OFF}"
section_separator=$'\n'
for result in "${up_to_date[@]}"; do
msg_success " ${result}"
done
fi
if (( ${#failure[@]} > 0 )); then
exit_code=1
printf "%sFailure%s\n" "${section_separator}${BOLD}${UNDERLINE}" "${ALL_OFF}"