Add --reinstall option to reinstall current version and show installation location when latest version is already installed
This commit is contained in:
@@ -286,7 +286,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
|
||||
@@ -476,12 +476,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 v0.10.0 # 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
|
||||
@@ -491,8 +493,9 @@ show_usage() {
|
||||
main() {
|
||||
local target_version=""
|
||||
local force_reinstall=false
|
||||
local reinstall_current=false
|
||||
local install_method="auto"
|
||||
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
@@ -508,6 +511,10 @@ main() {
|
||||
force_reinstall=true
|
||||
shift
|
||||
;;
|
||||
-r|--reinstall)
|
||||
reinstall_current=true
|
||||
shift
|
||||
;;
|
||||
-p|--package)
|
||||
install_method="package"
|
||||
shift
|
||||
@@ -533,11 +540,24 @@ main() {
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
print_warning "Not running as root. Some operations may require sudo."
|
||||
fi
|
||||
|
||||
|
||||
# Detect system
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user