Skip to content

Commit 1cc8a9d

Browse files
committed
cleanup
1 parent 1a73644 commit 1cc8a9d

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

eng/scripts/get-aspire-cli.sh

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,18 @@ readonly RESET='\033[0m'
1919
INSTALL_PATH=""
2020
VERSION=""
2121
QUALITY=""
22-
OS=""
23-
ARCH=""
22+
OS_ARG=""
23+
ARCH_ARG=""
2424
SHOW_HELP=false
2525
VERBOSE=false
2626
KEEP_ARCHIVE=false
2727
DRY_RUN=false
28+
HOST_OS="unset"
2829
DEFAULT_QUALITY="release"
2930

30-
# =====================
31-
# Shared helpers block
32-
# =====================
33-
3431
# Function to show help
3532
show_help() {
36-
cat << 'EOF'
33+
cat << EOF
3734
Aspire CLI Download Script
3835
3936
DESCRIPTION:
@@ -51,7 +48,7 @@ DESCRIPTION:
5148
USAGE:
5249
./get-aspire-cli.sh [OPTIONS]
5350
54-
-i, --install-path PATH Directory to install the CLI (default: $HOME/.aspire)
51+
-i, --install-path PATH Directory to install the CLI (default: $HOME/.aspire/bin)
5552
-q, --quality QUALITY Quality to download (default: ${DEFAULT_QUALITY}). Supported values: dev, staging, release
5653
--version VERSION Version of the Aspire CLI to download (default: unset)
5754
--os OS Operating system (default: auto-detect)
@@ -115,7 +112,7 @@ parse_args() {
115112
say_info "Use --help for usage information."
116113
exit 1
117114
fi
118-
OS="$2"
115+
OS_ARG="$2"
119116
shift 2
120117
;;
121118
--arch)
@@ -124,7 +121,7 @@ parse_args() {
124121
say_info "Use --help for usage information."
125122
exit 1
126123
fi
127-
ARCH="$2"
124+
ARCH_ARG="$2"
128125
shift 2
129126
;;
130127
-k|--keep-archive)
@@ -677,17 +674,17 @@ construct_aspire_cli_url() {
677674
# Function to download and install archive
678675
download_and_install_archive() {
679676
local temp_dir="$1"
680-
local os arch runtimeIdentifier url filename checksum_url checksum_filename extension
677+
local target_os="$2"
678+
local target_arch="$3"
679+
680+
local runtimeIdentifier url filename checksum_url checksum_filename extension
681681
local cli_exe cli_path
682682

683-
# Construct the runtime identifier from inputs (or detect)
684-
if ! runtimeIdentifier=$(get_runtime_identifier "${OS}" "${ARCH}"); then
685-
return 1
686-
fi
687-
os="${runtimeIdentifier%%-*}"
683+
# Construct the runtime identifier using the function
684+
runtimeIdentifier=$(get_runtime_identifier "$target_os" "$target_arch")
688685

689686
# Determine file extension based on OS
690-
if [[ "$os" == "win" ]]; then
687+
if [[ "$target_os" == "win" ]]; then
691688
extension="zip"
692689
else
693690
extension="tar.gz"
@@ -727,7 +724,7 @@ download_and_install_archive() {
727724
return 1
728725
fi
729726

730-
if [[ "$os" == "win" ]]; then
727+
if [[ "$target_os" == "win" ]]; then
731728
cli_exe="aspire.exe"
732729
else
733730
cli_exe="aspire"
@@ -745,6 +742,8 @@ if [[ "$SHOW_HELP" == true ]]; then
745742
exit 0
746743
fi
747744

745+
HOST_OS=$(detect_os)
746+
748747
# Validate that both --version and --quality are not provided together
749748
if [[ -n "$VERSION" && -n "$QUALITY" ]]; then
750749
say_error "Cannot specify both --version and --quality. Use --version for a specific version or --quality for a quality level."
@@ -760,8 +759,8 @@ fi
760759

761760
# Set default install path if not provided
762761
if [[ -z "$INSTALL_PATH" ]]; then
763-
INSTALL_PATH="$HOME/.aspire"
764-
INSTALL_PATH_UNEXPANDED="\$HOME/.aspire"
762+
INSTALL_PATH="$HOME/.aspire/bin"
763+
INSTALL_PATH_UNEXPANDED="\$HOME/.aspire/bin"
765764
else
766765
INSTALL_PATH_UNEXPANDED="$INSTALL_PATH"
767766
fi
@@ -771,7 +770,7 @@ temp_dir=$(new_temp_dir "aspire-cli-download")
771770
trap 'remove_temp_dir "$temp_dir"' EXIT
772771

773772
# Download and install the archive
774-
if ! download_and_install_archive "$temp_dir"; then
773+
if ! download_and_install_archive "$temp_dir" "$OS_ARG" "$ARCH_ARG"; then
775774
exit 1
776775
fi
777776

0 commit comments

Comments
 (0)