You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# @description Determine if a flag was passed as an argument
95
+
# @arg $1 string Flag name to test for
96
+
# @arg $@ string Rest of the arguments to search through
97
+
bake.has_flag() {
98
+
local flag_name="$1"
99
+
100
+
if [ -z"$flag_name" ];then
101
+
bake.die "Argument must not be empty"
102
+
fi
103
+
if!shift;then
104
+
bake.die 'Failed to shift'
105
+
fi
106
+
107
+
local arg=
108
+
for arg;do
109
+
if [ "$arg"="$flag_name" ];then
110
+
return 0
111
+
fi
112
+
done;unset -v arg
113
+
114
+
return 1
115
+
}
116
+
94
117
# @description Change the behavior of Bake. See [guide.md](./docs/guide.md) for details
95
118
# @arg $1 string Name of config property to change
96
119
# @arg $2 string New value of config property
@@ -101,21 +124,26 @@ bake.cfg() {
101
124
case$cfgin
102
125
stacktrace)
103
126
case$valuein
104
-
yes|no) __bake_cfg_stacktrace=$value ;;
105
-
*) __bake_internal_die2 "Config property '$cfg' accepts only either 'yes' or 'no'" ;;
127
+
yes) __bake_internal_warn "Passing either 'yes' or 'no' as a value for 'bake.cfg stacktrace' is deprecated. Instead, use either 'on' or 'off'"; __bake_cfg_stacktrace='on' ;;
128
+
no) __bake_internal_warn "Passing either 'yes' or 'no' as a value for 'bake.cfg stacktrace' is deprecated. Instead, use either 'on' or 'off'"; __bake_cfg_stacktrace='off' ;;
129
+
on|off) __bake_cfg_stacktrace=$value ;;
130
+
*) __bake_internal_die2 "Config property '$cfg' accepts only either 'on' or 'off'" ;;
106
131
esac
107
132
;;
108
133
pedantic-task-cd)
109
134
case$valuein
110
-
yes) trap'__bake_trap_debug''DEBUG' ;;
111
-
no) trap - 'DEBUG' ;;
112
-
*) __bake_internal_die2 "Config property '$cfg' accepts only either 'yes' or 'no'" ;;
135
+
yes) __bake_internal_warn "Passing either 'yes' or 'no' as a value for 'bake.cfg pedantic-task-cd' is deprecated. Instead, use either 'on' or 'off'";trap'__bake_trap_debug''DEBUG' ;;
136
+
no) __bake_internal_warn "Passing either 'yes' or 'no' as a value for 'bake.cfg pedantic-task-cd' is deprecated. Instead, use either 'on' or 'off'";trap - 'DEBUG' ;;
137
+
on) trap'__bake_trap_debug''DEBUG' ;;
138
+
off) trap - 'DEBUG' ;;
139
+
*) __bake_internal_die2 "Config property '$cfg' accepts only either 'on' or 'off'" ;;
113
140
esac
114
141
;;
115
142
big-print)
116
143
case$valuein
117
-
yes|no) ;;
118
-
*) __bake_internal_die2 "Config property '$cfg' accepts only either 'yes' or 'no'" ;;
144
+
yes|no) __bake_internal_warn "Passing either 'yes' or 'no' as a value for 'bake.cfg big-print' is deprecated. Instead, use either 'on' or 'off'" ;;
145
+
on|off) ;;
146
+
*) __bake_internal_die2 "Config property '$cfg' accepts only either 'on' or 'off'" ;;
119
147
esac
120
148
;;
121
149
*)
@@ -127,7 +155,7 @@ bake.cfg() {
127
155
# @description Prints stacktrace
128
156
# @internal
129
157
__bake_print_stacktrace() {
130
-
if [ "$__bake_cfg_stacktrace"='yes' ];then
158
+
if [ "$__bake_cfg_stacktrace"='on' ];then
131
159
if __bake_is_color;then
132
160
printf'\033[4m%s\033[0m\n''Stacktrace:'
133
161
else
@@ -173,11 +201,17 @@ __bake_trap_debug() {
173
201
# @exitcode 1 if should not print color
174
202
# @internal
175
203
__bake_is_color() {
176
-
if [[ -v NO_COLOR ||$TERM== dumb ]];then
204
+
local fd="1"
205
+
206
+
if [[ ${NO_COLOR+x}||"$TERM"='dumb' ]];then
177
207
return 1
178
-
else
208
+
fi
209
+
210
+
if [ -t"$fd" ];then
179
211
return 0
180
212
fi
213
+
214
+
return 1
181
215
}
182
216
183
217
# @description Calls `__bake_internal_error` and terminates with code 1
@@ -240,11 +274,22 @@ __bake_print_tasks() {
240
274
local str=
241
275
242
276
# shellcheck disable=SC1007,SC2034
243
-
local regex="^(([[:space:]]*function[[:space:]]*)?task\.(.*?)\(\)).*"
277
+
local regex="^([[:space:]]*function[[:space:]]*)?task\.(.*?)\(\)[[:space:]]*\{[[:space:]]*(#[[:space:]]*(.*))?"
244
278
local line=
245
279
while IFS= read -r line || [ -n"$line" ];do
246
280
if [[ "$line"=~$regex ]];then
247
-
str+=" -> ${BASH_REMATCH[3]}"$'\n'
281
+
str+=" -> ${BASH_REMATCH[2]}"
282
+
283
+
local task_comment=${BASH_REMATCH[4]}
284
+
if [ -n"$task_comment" ];then
285
+
if __bake_is_color;then
286
+
str+=$'\033[3m'"($task_comment)"$'\033[0m'
287
+
else
288
+
str+=" ($task_comment)"
289
+
fi
290
+
fi
291
+
292
+
str+=$'\n'
248
293
fi
249
294
done<"$BAKE_FILE";unset -v line
250
295
@@ -265,7 +310,7 @@ __bake_print_tasks() {
265
310
__bake_print_big() {
266
311
local print_text="$1"
267
312
268
-
if [ "$__bake_cfg_big_print"='no' ];then
313
+
if [ "$__bake_cfg_big_print"='off' ];then
269
314
return
270
315
fi
271
316
@@ -302,7 +347,6 @@ __bake_parse_args() {
302
347
unset REPLY; REPLY=
303
348
local -i total_shifts=0
304
349
305
-
# FIXME: bug for when passing -v to child task argument
0 commit comments