@@ -19,21 +19,18 @@ readonly RESET='\033[0m'
19
19
INSTALL_PATH=" "
20
20
VERSION=" "
21
21
QUALITY=" "
22
- OS =" "
23
- ARCH =" "
22
+ OS_ARG =" "
23
+ ARCH_ARG =" "
24
24
SHOW_HELP=false
25
25
VERBOSE=false
26
26
KEEP_ARCHIVE=false
27
27
DRY_RUN=false
28
+ HOST_OS=" unset"
28
29
DEFAULT_QUALITY=" release"
29
30
30
- # =====================
31
- # Shared helpers block
32
- # =====================
33
-
34
31
# Function to show help
35
32
show_help () {
36
- cat << ' EOF '
33
+ cat << EOF
37
34
Aspire CLI Download Script
38
35
39
36
DESCRIPTION:
@@ -51,7 +48,7 @@ DESCRIPTION:
51
48
USAGE:
52
49
./get-aspire-cli.sh [OPTIONS]
53
50
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 )
55
52
-q, --quality QUALITY Quality to download (default: ${DEFAULT_QUALITY} ). Supported values: dev, staging, release
56
53
--version VERSION Version of the Aspire CLI to download (default: unset)
57
54
--os OS Operating system (default: auto-detect)
@@ -115,7 +112,7 @@ parse_args() {
115
112
say_info " Use --help for usage information."
116
113
exit 1
117
114
fi
118
- OS =" $2 "
115
+ OS_ARG =" $2 "
119
116
shift 2
120
117
;;
121
118
--arch)
@@ -124,7 +121,7 @@ parse_args() {
124
121
say_info " Use --help for usage information."
125
122
exit 1
126
123
fi
127
- ARCH =" $2 "
124
+ ARCH_ARG =" $2 "
128
125
shift 2
129
126
;;
130
127
-k|--keep-archive)
@@ -677,17 +674,17 @@ construct_aspire_cli_url() {
677
674
# Function to download and install archive
678
675
download_and_install_archive () {
679
676
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
681
681
local cli_exe cli_path
682
682
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 " )
688
685
689
686
# Determine file extension based on OS
690
- if [[ " $os " == " win" ]]; then
687
+ if [[ " $target_os " == " win" ]]; then
691
688
extension=" zip"
692
689
else
693
690
extension=" tar.gz"
@@ -727,7 +724,7 @@ download_and_install_archive() {
727
724
return 1
728
725
fi
729
726
730
- if [[ " $os " == " win" ]]; then
727
+ if [[ " $target_os " == " win" ]]; then
731
728
cli_exe=" aspire.exe"
732
729
else
733
730
cli_exe=" aspire"
@@ -745,6 +742,8 @@ if [[ "$SHOW_HELP" == true ]]; then
745
742
exit 0
746
743
fi
747
744
745
+ HOST_OS=$( detect_os)
746
+
748
747
# Validate that both --version and --quality are not provided together
749
748
if [[ -n " $VERSION " && -n " $QUALITY " ]]; then
750
749
say_error " Cannot specify both --version and --quality. Use --version for a specific version or --quality for a quality level."
760
759
761
760
# Set default install path if not provided
762
761
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 "
765
764
else
766
765
INSTALL_PATH_UNEXPANDED=" $INSTALL_PATH "
767
766
fi
@@ -771,7 +770,7 @@ temp_dir=$(new_temp_dir "aspire-cli-download")
771
770
trap ' remove_temp_dir "$temp_dir"' EXIT
772
771
773
772
# 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
775
774
exit 1
776
775
fi
777
776
0 commit comments