Skip to content

Commit c99b828

Browse files
committed
add enable_env_var_names_array setting
1 parent 1096002 commit c99b828

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

lib/bashly/libraries/settings/settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ enable_bash3_bouncer: always
7777
enable_view_markers: development
7878
enable_inspect_args: development
7979
enable_deps_array: always
80+
enable_env_var_names_array: always
8081

8182
# Display various usage elements in color by providing the name of the color
8283
# function. The value for each property is a name of a function that is

lib/bashly/views/command/environment_variables_filter.gtx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ if environment_variables.any?
22
= view_marker
33
= render(:environment_variables_default)
44

5-
environment_variables.each do |env_var|
6-
> env_var_names+=("{{ env_var.name.upcase }}")
5+
if Settings.enabled? :env_var_names_array
6+
environment_variables.each do |env_var|
7+
> env_var_names+=("{{ env_var.name.upcase }}")
8+
end
79
end
810
end
911

lib/bashly/views/command/inspect_args.gtx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ if Settings.enabled? :deps_array
3131
> fi
3232
>
3333
end
34-
> if ((${#env_var_names[@]})); then
35-
> readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort)
36-
> echo
37-
> echo "environment variables:"
38-
> for k in "${sorted_names[@]}"; do
39-
> echo "- \$$k = ${!k:-}"
40-
> done
41-
> fi
34+
if Settings.enabled? :env_var_names_array
35+
> if ((${#env_var_names[@]})); then
36+
> readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort)
37+
> echo
38+
> echo "environment variables:"
39+
> for k in "${sorted_names[@]}"; do
40+
> echo "- \$$k = ${!k:-}"
41+
> done
42+
> fi
43+
end
4244
> }
4345
>

lib/bashly/views/command/run.gtx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ if Settings.enabled? :deps_array
66
> declare -g -A deps=()
77
end
88
> declare -g -a other_args=()
9-
> declare -g -a env_var_names=()
9+
if Settings.enabled? :env_var_names_array
10+
> declare -g -a env_var_names=()
11+
end
1012
> declare -g -a input=()
1113
if has_unique_args_or_flags?
1214
> declare -g -A unique_lookup=()

schemas/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,18 @@
189189
],
190190
"default": "always"
191191
},
192+
"enable_env_var_names_array": {
193+
"title": "enable_env_var_names_array",
194+
"description": "Whether to include the code for the env_var_names array in the generated script\nhttps://bashly.dannyb.co/usage/settings/#enable_env_var_names_array",
195+
"type": "string",
196+
"enum": [
197+
"development",
198+
"production",
199+
"always",
200+
"never"
201+
],
202+
"default": "always"
203+
},
192204
"partials_extension": {
193205
"title": "partials extension",
194206
"description": "The extension to use when reading/writing partial script snippets\nhttps://bashly.dannyb.co/usage/settings/#partials_extension",

0 commit comments

Comments
 (0)