@@ -117,19 +117,16 @@ get_latest_version() {
117117 log_error " Failed to fetch the latest release version. Please check your internet connection."
118118 fi
119119
120- # Remove 'v' prefix if present
121- VERSION=${VERSION# v}
122-
123120 log_info " Latest version: $VERSION "
124121}
125122
126123# Download binary
127124download_binary () {
128125 local binary_name=" ${BINARY_NAME} -${PLATFORM} "
129- local download_url=" https://github.com/$REPO /releases/download/v $VERSION /${binary_name} .tar.gz"
126+ local download_url=" https://github.com/$REPO /releases/download/$VERSION /${binary_name} .tar.gz"
130127 local archive_path=" $TMP_DIR /${binary_name} .tar.gz"
131128
132- log_info " Downloading $binary_name v $VERSION ..."
129+ log_info " Downloading $binary_name $VERSION ..."
133130 log_info " URL: $download_url "
134131
135132 if command -v curl & > /dev/null; then
@@ -303,7 +300,7 @@ main() {
303300 VERSION=" $2 "
304301 shift 2
305302 else
306- log_error " --version requires a version number"
303+ log_error " --version requires a version number (use 'latest' to get the latest version) "
307304 fi
308305 ;;
309306 --install-dir)
@@ -320,7 +317,7 @@ main() {
320317 echo " Usage: $0 [OPTIONS]"
321318 echo
322319 echo " Options:"
323- echo " --version VERSION Install specific version (default: latest)"
320+ echo " --version VERSION Install specific version or 'latest' (default: latest)"
324321 echo " --install-dir DIR Install directory (default: /usr/local/bin)"
325322 echo " -h, --help Show this help message"
326323 echo
@@ -329,6 +326,7 @@ main() {
329326 echo
330327 echo " Examples:"
331328 echo " $0 # Install latest version"
329+ echo " $0 --version latest # Explicitly install latest version"
332330 echo " $0 --version 1.0.0 # Install specific version"
333331 echo " $0 --install-dir ~/.local/bin # Install to custom directory"
334332 echo " INSTALL_DIR=~/.local/bin $0 # Using environment variable"
@@ -344,9 +342,12 @@ main() {
344342 detect_platform
345343 check_permissions
346344
347- # Get version if not specified
345+ # Get version if not specified or if "latest" was explicitly requested
348346 if [[ -z " $VERSION " ]]; then
349347 get_latest_version
348+ elif [[ " $VERSION " == " latest" ]]; then
349+ log_info " Fetching latest version..."
350+ get_latest_version
350351 else
351352 log_info " Using specified version: $VERSION "
352353 fi
0 commit comments