From cc5a29d8888ce8f0955a741d8c39c08856cd1051 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Fri, 5 Dec 2025 13:02:14 +0000 Subject: [PATCH 1/3] - Move global variable declarations after environment variable declarations --- lib/bashly/views/command/initialize.gtx | 2 +- spec/fixtures/workspaces/var-order/.gitignore | 1 + spec/fixtures/workspaces/var-order/README.md | 3 +++ spec/fixtures/workspaces/var-order/src/bashly.yml | 12 ++++++++++++ .../workspaces/var-order/src/root_command.sh | 2 ++ spec/fixtures/workspaces/var-order/test.sh | 6 ++++++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/workspaces/var-order/.gitignore create mode 100644 spec/fixtures/workspaces/var-order/README.md create mode 100644 spec/fixtures/workspaces/var-order/src/bashly.yml create mode 100644 spec/fixtures/workspaces/var-order/src/root_command.sh create mode 100644 spec/fixtures/workspaces/var-order/test.sh diff --git a/lib/bashly/views/command/initialize.gtx b/lib/bashly/views/command/initialize.gtx index 0b61fdec..fb019ef4 100644 --- a/lib/bashly/views/command/initialize.gtx +++ b/lib/bashly/views/command/initialize.gtx @@ -6,8 +6,8 @@ if root_command? > - = render(:variables).indent(2) = render(:environment_variables_default).indent 2 + = render(:variables).indent(2) end if user_file_exist?('initialize') diff --git a/spec/fixtures/workspaces/var-order/.gitignore b/spec/fixtures/workspaces/var-order/.gitignore new file mode 100644 index 00000000..76ec9f59 --- /dev/null +++ b/spec/fixtures/workspaces/var-order/.gitignore @@ -0,0 +1 @@ +cli \ No newline at end of file diff --git a/spec/fixtures/workspaces/var-order/README.md b/spec/fixtures/workspaces/var-order/README.md new file mode 100644 index 00000000..cd3a73b3 --- /dev/null +++ b/spec/fixtures/workspaces/var-order/README.md @@ -0,0 +1,3 @@ +This fixture ensures that environment varaibles are declared and populated +begore variables defined in bashly.yml, to allow using the values from them +in the variables. diff --git a/spec/fixtures/workspaces/var-order/src/bashly.yml b/spec/fixtures/workspaces/var-order/src/bashly.yml new file mode 100644 index 00000000..3ebdb274 --- /dev/null +++ b/spec/fixtures/workspaces/var-order/src/bashly.yml @@ -0,0 +1,12 @@ +name: cli +help: Ensure env var / var order +version: 0.1.0 + +environment_variables: +- name: cli_config_file + help: Path to config file + default: config.yaml + +variables: +- name: config_file + value: $CLI_CONFIG_FILE diff --git a/spec/fixtures/workspaces/var-order/src/root_command.sh b/spec/fixtures/workspaces/var-order/src/root_command.sh new file mode 100644 index 00000000..afadcf1c --- /dev/null +++ b/spec/fixtures/workspaces/var-order/src/root_command.sh @@ -0,0 +1,2 @@ +inspect_args +echo "\$config_file == \$CLI_CONFIG_FILE == $config_file" diff --git a/spec/fixtures/workspaces/var-order/test.sh b/spec/fixtures/workspaces/var-order/test.sh new file mode 100644 index 00000000..a56dc8d8 --- /dev/null +++ b/spec/fixtures/workspaces/var-order/test.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -x + +bundle exec bashly generate +./cli \ No newline at end of file From 4cdfed5d564c0def791230f05f8562253ae2c350 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Fri, 5 Dec 2025 13:02:54 +0000 Subject: [PATCH 2/3] approval --- spec/approvals/fixtures/var-order | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 spec/approvals/fixtures/var-order diff --git a/spec/approvals/fixtures/var-order b/spec/approvals/fixtures/var-order new file mode 100644 index 00000000..4cebc48b --- /dev/null +++ b/spec/approvals/fixtures/var-order @@ -0,0 +1,11 @@ ++ bundle exec bashly generate +creating user files in src +skipped src/root_command.sh (exists) +created ./cli +run ./cli --help to test your bash script ++ ./cli +args: none + +environment variables: +- $CLI_CONFIG_FILE = config.yaml +$config_file == $CLI_CONFIG_FILE == config.yaml From 14830e0159e2f35896687815b132c0f252d14119 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Fri, 5 Dec 2025 13:07:27 +0000 Subject: [PATCH 3/3] typo --- spec/fixtures/workspaces/var-order/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/fixtures/workspaces/var-order/README.md b/spec/fixtures/workspaces/var-order/README.md index cd3a73b3..e8a4b9b5 100644 --- a/spec/fixtures/workspaces/var-order/README.md +++ b/spec/fixtures/workspaces/var-order/README.md @@ -1,3 +1,3 @@ -This fixture ensures that environment varaibles are declared and populated +This fixture ensures that environment variables are declared and populated begore variables defined in bashly.yml, to allow using the values from them in the variables.