Skip to content

Commit 4f9c9c6

Browse files
authored
Merge pull request #334 from DannyBen/fix/env-var
Fix environment variables
2 parents ca8ca7b + e8fc115 commit 4f9c9c6

File tree

13 files changed

+57
-16
lines changed

13 files changed

+57
-16
lines changed

lib/bashly/config_validator.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ def assert_env_var(key, value)
132132
assert_optional_string "#{key}.default", value['default']
133133
assert_boolean "#{key}.required", value['required']
134134
assert_boolean "#{key}.private", value['private']
135-
136-
if value['private']
137-
assert value['default'], "#{key}.private makes no sense without default"
138-
end
139135
end
140136

141137
def assert_command(key, value)

lib/bashly/docs/env.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ environment_variable.name:
3636
help: Your API key
3737
3838
environment_variable.private:
39-
help: Specify that this environment variable should not be advertised in the usage text. Only makes sense when accompanied by `default`.
39+
help: Specify that this environment variable should not be advertised in the usage text.
4040
url: https://bashly.dannyb.co/configuration/environment-variable/#private
4141
example: |-
4242
environment_variables:

lib/bashly/script/command.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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 only flags that are not private
221226
def public_flags
222227
flags.reject(&:private)

lib/bashly/views/command/long_usage.gtx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
= render(:usage_flags).indent 2 if public_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
>

lib/bashly/views/command/usage_environment_variables.gtx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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
88
end
99

spec/approvals/cli/doc/full

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ environment_variable.name
517517
environment_variable.private
518518

519519
Specify that this environment variable should not be advertised in the usage
520-
text. Only makes sense when accompanied by default.
520+
text.
521521

522522
environment_variables:
523523
- name: editor
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+

spec/approvals/validations/env_var_private_without_default

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/fixtures/script/validations.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@
147147
default: development
148148
private: 1
149149

150-
:env_var_private_without_default:
151-
name: invalid
152-
help: env_var.private makes no sense without default
153-
environment_variables:
154-
- name: server_env
155-
private: true
156-
157150
:flag_long:
158151
name: invalid
159152
help: the long flag is not in the form of --force
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cli
2+
src/*.sh

0 commit comments

Comments
 (0)