Skip to content

Commit

Permalink
add enable_env_var_names_array setting
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyBen committed Dec 18, 2024
1 parent 1096002 commit c99b828
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/bashly/libraries/settings/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enable_bash3_bouncer: always
enable_view_markers: development
enable_inspect_args: development
enable_deps_array: always
enable_env_var_names_array: always

# Display various usage elements in color by providing the name of the color
# function. The value for each property is a name of a function that is
Expand Down
6 changes: 4 additions & 2 deletions lib/bashly/views/command/environment_variables_filter.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ if environment_variables.any?
= view_marker
= render(:environment_variables_default)

environment_variables.each do |env_var|
> env_var_names+=("{{ env_var.name.upcase }}")
if Settings.enabled? :env_var_names_array
environment_variables.each do |env_var|
> env_var_names+=("{{ env_var.name.upcase }}")
end
end
end

Expand Down
18 changes: 10 additions & 8 deletions lib/bashly/views/command/inspect_args.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ if Settings.enabled? :deps_array
> fi
>
end
> if ((${#env_var_names[@]})); then
> readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort)
> echo
> echo "environment variables:"
> for k in "${sorted_names[@]}"; do
> echo "- \$$k = ${!k:-}"
> done
> fi
if Settings.enabled? :env_var_names_array
> if ((${#env_var_names[@]})); then
> readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort)
> echo
> echo "environment variables:"
> for k in "${sorted_names[@]}"; do
> echo "- \$$k = ${!k:-}"
> done
> fi
end
> }
>
4 changes: 3 additions & 1 deletion lib/bashly/views/command/run.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ if Settings.enabled? :deps_array
> declare -g -A deps=()
end
> declare -g -a other_args=()
> declare -g -a env_var_names=()
if Settings.enabled? :env_var_names_array
> declare -g -a env_var_names=()
end
> declare -g -a input=()
if has_unique_args_or_flags?
> declare -g -A unique_lookup=()
Expand Down
12 changes: 12 additions & 0 deletions schemas/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@
],
"default": "always"
},
"enable_env_var_names_array": {
"title": "enable_env_var_names_array",
"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",
"type": "string",
"enum": [
"development",
"production",
"always",
"never"
],
"default": "always"
},
"partials_extension": {
"title": "partials extension",
"description": "The extension to use when reading/writing partial script snippets\nhttps://bashly.dannyb.co/usage/settings/#partials_extension",
Expand Down

0 comments on commit c99b828

Please sign in to comment.