Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2024-01-18 03:33:13 +0100
committerLevente Polyak <anthraxx@archlinux.org>2024-01-22 19:45:04 +0100
commitb258bb3b7c55d06bad108400450acd32cff05366 (patch)
tree426d1e27c1b295998e088cb1e9cb72dee7ce1e6f /src/lib
parent08ece1640b360d741bd08dc6dc028a42682aa4ed (diff)
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>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/version/check.sh25
-rw-r--r--src/lib/version/upgrade.sh21
2 files changed, 42 insertions, 4 deletions
diff --git a/src/lib/version/check.sh b/src/lib/version/check.sh
index fba2d1a..9bc29c1 100644
--- a/src/lib/version/check.sh
+++ b/src/lib/version/check.sh
@@ -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'
diff --git a/src/lib/version/upgrade.sh b/src/lib/version/upgrade.sh
index 9f884d0..70513ce 100644
--- a/src/lib/version/upgrade.sh
+++ b/src/lib/version/upgrade.sh
@@ -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}"