File tree Expand file tree Collapse file tree 7 files changed +68
-6
lines changed
spec/fixtures/workspaces/environment-variables-initialize Expand file tree Collapse file tree 7 files changed +68
-6
lines changed Original file line number Diff line number Diff line change 1+ if default_environment_variables.any?
2+ = view_marker
3+
4+ if default_environment_variables.any?
5+ default_environment_variables.each do |env_var|
6+ > export {{ env_var.name.upcase }}="${<%= env_var.name.upcase %>:-<%= env_var.default %>}"
7+ end
8+ end
9+ end
Original file line number Diff line number Diff line change 11if default_environment_variables.any? or required_environment_variables.any?
22 = view_marker
3-
4- if default_environment_variables.any?
5- default_environment_variables.each do |env_var|
6- > export {{ env_var.name.upcase }}="${<%= env_var.name.upcase %>:-<%= env_var.default %>}"
7- end
8- end
3+ = render(:environment_variables_default)
94
105 if required_environment_variables.any?
116 required_environment_variables.each do |env_var|
Original file line number Diff line number Diff line change 66> {{ Settings.strict ? "set -euo pipefail" : "set -e" }}
77>
88
9+ if root_command?
10+ = render(:environment_variables_default).indent 2
11+ end
12+
913= load_user_file("initialize.sh", placeholder: false).indent 2
1014
1115> }
Original file line number Diff line number Diff line change 1+ cli
2+ src /* .sh
Original file line number Diff line number Diff line change 1+ This fixture tests that default values for environment variables exist in
2+ the initialize function, and that required environment variables are NOT
3+ blocking --help.
4+
5+ Reference issue: https://github.com/DannyBen/bashly/issues/265
Original file line number Diff line number Diff line change 1+ name : cli
2+ help : Sample application
3+ version : 0.1.0
4+
5+ environment_variables :
6+ - name : api_key
7+ default : must-be-available-in-initialize
8+ help : Set your API key
9+ - name : config_path
10+ required : true
11+ help : Set the config path
12+
13+ commands :
14+ - name : download
15+ alias : d
16+ help : Download a file
17+
18+ args :
19+ - name : source
20+ help : URL to download from
21+ - name : target
22+ help : " Target filename (default: same as source)"
23+
24+ environment_variables :
25+ - name : default_target_location
26+ default : not-available-in-initialize
27+ help : Set the default location to download to
28+
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # This fixture tests that default values for environment variables exist in
4+ # the initialize function, and that required environment variables are NOT
5+ # blocking --help.
6+ # Reference issue: https://github.com/DannyBen/bashly/issues/265
7+
8+ rm -f ./src/download_command.sh
9+ rm -f ./cli
10+
11+ bundle exec bashly generate
12+
13+ set -x
14+
15+ ./cli
16+ export CONFIG_PATH=somepath
17+ ./cli download source
18+ export API_KEY=override-value
19+ ./cli
You can’t perform that action at this time.
0 commit comments