Skip to content

Commit ded2a3b

Browse files
committed
add default env var specs
1 parent a320ae8 commit ded2a3b

File tree

6 files changed

+44
-2
lines changed

6 files changed

+44
-2
lines changed

examples/environment-variables/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ name: cli
1111
help: Sample application that requires environment variables
1212
version: 0.1.0
1313

14-
# This option adds usage text to the help message in the generated script.
14+
# These two variable options add usage text to the help message in the
15+
# generated script.
16+
# In addition, the value of the variable `ENVIRONMENT` will be set to
17+
# `development` if it is not already set by the user.
1518
environment_variables:
1619
- name: api_key
1720
help: Set your API key
21+
- name: environment
22+
help: One of development, production or test
23+
default: development
1824

1925
commands:
2026
- name: verify
@@ -73,6 +79,9 @@ Environment Variables:
7379
API_KEY
7480
Set your API key
7581
82+
ENVIRONMENT
83+
One of development, production or test
84+
7685
7786
7887
```
@@ -116,5 +125,13 @@ missing required environment variable: MY_SECRET
116125
117126
```
118127

128+
### `$ ./cli verify`
129+
130+
```shell
131+
missing required environment variable: MY_SECRET
132+
133+
134+
```
135+
119136

120137

examples/environment-variables/cli

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ cli_usage() {
4444
echo " API_KEY"
4545
printf " Set your API key\n"
4646
echo
47+
48+
# :environment_variable.usage
49+
echo " ENVIRONMENT"
50+
printf " One of development, production or test\n"
51+
echo
4752

4853
fi
4954
}
@@ -114,6 +119,8 @@ cli_verify_command() {
114119
inspect_args
115120

116121
echo "environment:"
122+
echo "- API_KEY=$API_KEY"
123+
echo "- ENVIRONMENT=$ENVIRONMENT"
117124
echo "- MY_SECRET=$MY_SECRET"
118125
}
119126

examples/environment-variables/src/bashly.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ name: cli
22
help: Sample application that requires environment variables
33
version: 0.1.0
44

5-
# This option adds usage text to the help message in the generated script.
5+
# These two variable options add usage text to the help message in the
6+
# generated script.
7+
# In addition, the value of the variable `ENVIRONMENT` will be set to
8+
# `development` if it is not already set by the user.
69
environment_variables:
710
- name: api_key
811
help: Set your API key
12+
- name: environment
13+
help: One of development, production or test
14+
default: development
915

1016
commands:
1117
- name: verify

examples/environment-variables/src/verify_command.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ echo "# you can edit it freely and regenerate (it will not be overwritten)"
44
inspect_args
55

66
echo "environment:"
7+
echo "- API_KEY=$API_KEY"
8+
echo "- ENVIRONMENT=$ENVIRONMENT"
79
echo "- MY_SECRET=$MY_SECRET"

examples/environment-variables/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ bashly generate
99
./cli verify -h
1010
./cli verify
1111
MY_SECRET="there is no spoon" ./cli verify
12+
ENVIRONMENT=production ./cli verify

spec/approvals/examples/environment-variables

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Environment Variables:
3737
API_KEY
3838
Set your API key
3939

40+
ENVIRONMENT
41+
One of development, production or test
42+
Default: development
43+
4044
+ ./cli verify -h
4145
cli verify - Verify your user
4246

@@ -63,4 +67,9 @@ missing required environment variable: MY_SECRET
6367
# you can edit it freely and regenerate (it will not be overwritten)
6468
args: none
6569
environment:
70+
- API_KEY=
71+
- ENVIRONMENT=development
6672
- MY_SECRET=there is no spoon
73+
+ ENVIRONMENT=production
74+
+ ./cli verify
75+
missing required environment variable: MY_SECRET

0 commit comments

Comments
 (0)