File tree Expand file tree Collapse file tree 8 files changed +55
-2
lines changed
fixtures/workspaces/environment-variables-private Expand file tree Collapse file tree 8 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,11 @@ def public_commands
217217 commands . reject ( &:private )
218218 end
219219
220+ # Returns only environment variables that are not private
221+ def public_environment_variables
222+ environment_variables . reject ( &:private )
223+ end
224+
220225 # Returns true if one of the args is repeatable
221226 def repeatable_arg_exist?
222227 args . select ( &:repeatable ) . any?
Original file line number Diff line number Diff line change 66= render(:usage_flags).indent 2 if flags.any?
77= render(:usage_fixed_flags).indent 2
88= render(:usage_args).indent 2 if args.any? or catch_all.help
9- = render(:usage_environment_variables).indent 2 if environment_variables .any?
9+ = render(:usage_environment_variables).indent 2 if public_environment_variables .any?
1010= render(:usage_examples).indent 2 if examples
1111= render(:footer).indent 2 if footer
1212>
Original file line number Diff line number Diff line change 33> printf "%s\n" "{{ strings[:environment_variables].color(:caption) }}"
44>
55
6- environment_variables.reject(&:private) .each do |env_var|
6+ public_environment_variables .each do |env_var|
77 = env_var.render :usage
88end
99
Original file line number Diff line number Diff line change 1+ creating user files in src
2+ created src/initialize.sh
3+ created src/root_command.sh
4+ created ./cli
5+ run ./cli --help to test your bash script
6+ + ./cli --help
7+ cli
8+
9+ Usage:
10+ cli
11+ cli --help | -h
12+ cli --version | -v
13+
14+ Options:
15+ --help, -h
16+ Show this help
17+
18+ --version, -v
19+ Show version number
20+
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 there is no group caption if all env vars are private
2+
3+ Reference issue: https://github.com/DannyBen/bashly/issues/331
Original file line number Diff line number Diff line change 1+ name : cli
2+ version : 0.1.0
3+
4+ environment_variables :
5+ - name : example
6+ default : value
7+ private : true
8+ help : A help message for EXAMPLE
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/* .sh
9+ rm -f ./cli
10+
11+ bundle exec bashly generate
12+
13+ set -x
14+
15+ ./cli --help
You can’t perform that action at this time.
0 commit comments