@@ -99,12 +99,42 @@ action_deploy() {
99
99
100
100
validate_project_setup
101
101
102
- # Set deployment environment for first argument that doesn't start with a dash
103
- for arg in " $@ " ; do
104
- if [[ " $arg " != -* && -z " $deployment_environment " ]]; then
105
- deployment_environment=" $arg "
106
- break
107
- fi
102
+ # Process arguments
103
+ while [[ $# -gt 0 ]]; do
104
+ case " $1 " in
105
+ --user | -u)
106
+ ssh_user=" $2 "
107
+ shift 2
108
+ ;;
109
+ --compose-file | -c)
110
+ if [[ -n " $2 " && " $2 " != -* ]]; then
111
+ compose_files+=(" $2 " )
112
+ shift 2
113
+ else
114
+ echo " ${BOLD}${RED} ❌Error: '-c' option requires a Docker Compose file as argument.${RESET} "
115
+ exit 1
116
+ fi
117
+ ;;
118
+ --port | -p)
119
+ ssh_port=" $2 "
120
+ shift 2
121
+ ;;
122
+ --upgrade|-U)
123
+ SPIN_FORCE_INSTALL_GALAXY_DEPS=true
124
+ shift
125
+ ;;
126
+ -* )
127
+ echo " ${BOLD}${RED} ❌Error: Unknown option $1 ${RESET} "
128
+ exit 1
129
+ ;;
130
+ * )
131
+ # Only set deployment_environment if it hasn't been set yet
132
+ if [[ -z " $deployment_environment " ]]; then
133
+ deployment_environment=" $1 "
134
+ fi
135
+ shift
136
+ ;;
137
+ esac
108
138
done
109
139
110
140
# If no environment specified, default to production
@@ -162,39 +192,6 @@ action_deploy() {
162
192
ssh_user=" ${SPIN_SSH_USER:- " deploy" } "
163
193
spin_project_name=" ${SPIN_PROJECT_NAME:- " spin" } "
164
194
165
- # Process arguments
166
- while [[ $# -gt 0 ]]; do
167
- case " $1 " in
168
- --user | -u)
169
- ssh_user=" $2 "
170
- shift 2
171
- ;;
172
- --compose-file | -c)
173
- if [[ -n " $2 " && " $2 " != -* ]]; then
174
- compose_files+=(" $2 " )
175
- shift 2
176
- else
177
- echo " ${BOLD}${RED} ❌Error: '-c' option requires a Docker Compose file as argument.${RESET} "
178
- exit 1
179
- fi
180
- ;;
181
- --port | -p)
182
- ssh_port=" $2 "
183
- shift 2
184
- ;;
185
- --upgrade|-U)
186
- SPIN_FORCE_INSTALL_GALAXY_DEPS=true
187
- shift
188
- ;;
189
- * )
190
- if [[ -z " $deployment_environment " ]]; then # capture the first positional argument as environment
191
- deployment_environment=" $1 "
192
- fi
193
- shift
194
- ;;
195
- esac
196
- done
197
-
198
195
# Clean up services on exit
199
196
trap cleanup_on_exit EXIT
200
197
0 commit comments