Add --reinstall option to reinstall current version and show installation location when latest version is already installed

This commit is contained in:
kdusek
2025-11-13 17:51:07 +01:00
parent 979977d16e
commit 811f1b800c
3 changed files with 89 additions and 16 deletions

View File

@@ -198,7 +198,7 @@ check_update_needed() {
if compare_versions "$clean_latest" "$clean_current"; then
if [[ "$clean_latest" == "$clean_current" ]]; then
print_success "You already have the latest version ($current_version)"
print_success "You already have the latest version ($current_version) installed at $install_type location"
if [[ "$force_reinstall" == "true" ]]; then
print_status "Force reinstall requested, proceeding..."
return 0
@@ -492,12 +492,14 @@ show_usage() {
echo " -h, --help Show this help message"
echo " -v, --version Install specific version (default: latest)"
echo " -f, --force Force reinstall even if up-to-date"
echo " -r, --reinstall Reinstall the current installed version"
echo " -p, --package Force installation from package manager"
echo " -b, --binary Force installation from binary"
echo
echo "Examples:"
echo " $0 # Install latest version using best method"
echo " $0 -v v1.2.7 # Install specific version"
echo " $0 --reinstall # Reinstall current version"
echo " $0 --package # Force installation from package manager"
echo " $0 --binary # Force installation from binary"
echo
@@ -507,6 +509,7 @@ show_usage() {
main() {
local target_version=""
local force_reinstall=false
local reinstall_current=false
local install_method="auto"
# Parse command line arguments
@@ -524,6 +527,10 @@ main() {
force_reinstall=true
shift
;;
-r|--reinstall)
reinstall_current=true
shift
;;
-p|--package)
install_method="package"
shift
@@ -554,6 +561,19 @@ main() {
detect_os
ARCH=$(get_arch)
# Handle reinstall current version
if [[ "$reinstall_current" == "true" ]]; then
local current_info=$(get_current_version)
local current_version=$(echo "$current_info" | cut -d: -f1)
if [[ "$current_version" == "not_installed" ]]; then
print_error "No current version installed to reinstall"
exit 1
fi
target_version="$current_version"
force_reinstall=true
print_status "Reinstalling current version: $target_version"
fi
# Get latest version if not specified
if [[ -z "$target_version" ]]; then
get_latest_release