File tree Expand file tree Collapse file tree 6 files changed +44
-2
lines changed
examples/environment-variables Expand file tree Collapse file tree 6 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,16 @@ name: cli
1111help : Sample application that requires environment variables
1212version : 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.
1518environment_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
1925commands :
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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -2,10 +2,16 @@ name: cli
22help : Sample application that requires environment variables
33version : 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.
69environment_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
1016commands :
1117- name : verify
Original file line number Diff line number Diff line change @@ -4,4 +4,6 @@ echo "# you can edit it freely and regenerate (it will not be overwritten)"
44inspect_args
55
66echo " environment:"
7+ echo " - API_KEY=$API_KEY "
8+ echo " - ENVIRONMENT=$ENVIRONMENT "
79echo " - MY_SECRET=$MY_SECRET "
Original file line number Diff line number Diff line change @@ -9,3 +9,4 @@ bashly generate
99./cli verify -h
1010./cli verify
1111MY_SECRET=" there is no spoon" ./cli verify
12+ ENVIRONMENT=production ./cli verify
Original file line number Diff line number Diff 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
4145cli 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)
6468args: none
6569environment:
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
You can’t perform that action at this time.
0 commit comments