Skip to content

Commit e8ef35b

Browse files
committed
core: Introduce _GO_CORE_VERSION
It only makes sense to export this and make it discoverable via `./go vars`.
1 parent 17a69d2 commit e8ef35b

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

go-core.bash

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
#
33
# Framework for writing "./go" scripts in Bash.
44
#
5-
# Version: v1.0.0
6-
# URL: https://github.com/mbland/go-script-bash
7-
#
85
# To use this framework, create a bash script in the root directory of your
96
# project to act as the main './go' script. This script need not be named 'go',
107
# but it must contain the following as the first and last executable lines,
@@ -35,19 +32,25 @@ if [[ "${BASH_VERSINFO[0]}" -lt '3' || "${BASH_VERSINFO[1]}" -lt '2' ]]; then
3532
exit 1
3633
fi
3734

35+
# The version of the framework
36+
#
37+
# NOTE:
38+
# ----
39+
# This and other variables are exported, so that command scripts written in
40+
# languages other than Bash (and hence run in new processes) can access them.
41+
# See `./go vars` and `./go help vars`.
42+
declare -r -x _GO_CORE_VERSION='v1.0.0'
43+
44+
# The URL of the framework's original source repository
45+
declare -r -x _GO_CORE_URL='https://github.com/mbland/go-script-bash'
46+
3847
declare __go_orig_dir="$PWD"
3948
cd "${0%/*}" || exit 1
4049

4150
# Path to the project's root directory
4251
#
4352
# This is directory containing the main ./go script. All functions, commands,
4453
# and scripts are invoked relative to this directory.
45-
#
46-
# NOTE:
47-
# ----
48-
# This and other variables are exported, so that command scripts written in
49-
# languages other than Bash (and hence run in new processes) can access them.
50-
# See `./go vars` and `./go help vars`.
5154
declare -r -x _GO_ROOTDIR="$PWD"
5255

5356
if [[ "${BASH_SOURCE[0]:0:1}" != '/' ]]; then
@@ -104,9 +107,6 @@ declare -x _GO_CMD_NAME=
104107
# string with the arguments delimited by the ASCII NUL character ($'\0').
105108
declare -x _GO_CMD_ARGV=
106109

107-
# The URL of the framework's original source repository.
108-
declare -r -x _GO_CORE_URL='https://github.com/mbland/go-script-bash'
109-
110110
# The directory in which plugins are installed.
111111
declare _GO_PLUGINS_DIR=
112112

tests/vars.bats

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ quotify_expected() {
3535
'declare -ax _GO_CMD_NAME=([0]="vars")'
3636
"declare -rx _GO_CORE_DIR=\"$_GO_CORE_DIR\""
3737
"declare -rx _GO_CORE_URL=\"$_GO_CORE_URL\""
38+
"declare -rx _GO_CORE_VERSION=\"$_GO_CORE_VERSION\""
3839
'declare -a _GO_IMPORTED_MODULES=()'
3940
'declare -- _GO_PLUGINS_DIR=""'
4041
'declare -a _GO_PLUGINS_PATHS=()'
@@ -77,6 +78,7 @@ quotify_expected() {
7778
'declare -ax _GO_CMD_NAME=([0]="test-command" [1]="test-subcommand")'
7879
"declare -rx _GO_CORE_DIR=\"$_GO_CORE_DIR\""
7980
"declare -rx _GO_CORE_URL=\"$_GO_CORE_URL\""
81+
"declare -rx _GO_CORE_VERSION=\"$_GO_CORE_VERSION\""
8082
'declare -a _GO_IMPORTED_MODULES=([0]="complete" [1]="format")'
8183
"declare -- _GO_PLUGINS_DIR=\"$TEST_GO_PLUGINS_DIR\""
8284
"declare -a _GO_PLUGINS_PATHS=(${plugins_paths[*]})"
@@ -112,6 +114,7 @@ quotify_expected() {
112114
"_GO_CMD_NAME: test-command"$'\0'"test-subcommand" \
113115
"_GO_CORE_DIR: $_GO_CORE_DIR" \
114116
"_GO_CORE_URL: $_GO_CORE_URL" \
117+
"_GO_CORE_VERSION: $_GO_CORE_VERSION" \
115118
"_GO_ROOTDIR: $TEST_GO_ROOTDIR" \
116119
"_GO_SCRIPT: $TEST_GO_SCRIPT"
117120
}

0 commit comments

Comments
 (0)