From c143d8ff8ea15cebad957389978391b1c3ebab9a Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Fri, 4 Apr 2025 05:45:36 +0000 Subject: [PATCH 1/8] changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 738c5320..858f3cdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ======================================== +v1.2.11 - 2025-04-04 +---------------------------------------- + +- Fix quoted heredocs [`4b264646`](https://github.com/DannyBen/bashly/commit/4b264646) +- Compare [`v1.2.10..v1.2.11`](https://github.com/dannyben/bashly/compare/v1.2.10..v1.2.11) + + v1.2.10 - 2025-02-22 ---------------------------------------- From a735ee00db21cf5f6b64910cb1d118dc84491f1a Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Fri, 11 Apr 2025 11:32:38 +0000 Subject: [PATCH 2/8] - Drop support for Ruby 3.1 --- .github/workflows/static-analysis.yml | 4 ++-- .github/workflows/test.yml | 2 +- .rubocop.yml | 2 +- bashly.gemspec | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 74ad5f17..906fd3ae 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -30,7 +30,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: '3.4' bundler-cache: true - name: Generate all examples and fixtures @@ -65,7 +65,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: '3.4' bundler-cache: true - name: Generate all subjects diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5094722a..cd440da1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: LC_ALL: en_US.UTF-8 strategy: - matrix: { ruby: ['3.1', '3.2', '3.3', '3.4'] } + matrix: { ruby: ['3.2', '3.3', '3.4'] } steps: - name: Checkout code diff --git a/.rubocop.yml b/.rubocop.yml index 11fc5b8f..7584e828 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,7 +8,7 @@ inherit_gem: - rspec.yml AllCops: - TargetRubyVersion: 3.1 + TargetRubyVersion: 3.2 SuggestExtensions: false Exclude: - dev/**/* diff --git a/bashly.gemspec b/bashly.gemspec index c2712d35..f29bfc0f 100644 --- a/bashly.gemspec +++ b/bashly.gemspec @@ -13,10 +13,10 @@ Gem::Specification.new do |s| s.executables = ['bashly'] s.homepage = 'https://github.com/dannyben/bashly' s.license = 'MIT' - s.required_ruby_version = '>= 3.1' + s.required_ruby_version = '>= 3.2' - s.add_dependency 'colsole', '>= 0.8.1', '< 2' - s.add_dependency 'completely', '>= 0.6.1', '< 0.8' + s.add_dependency 'colsole', '~> 1.0' + s.add_dependency 'completely', '~> 0.7.0' s.add_dependency 'filewatcher', '~> 2.0' s.add_dependency 'gtx', '~> 0.1.1' s.add_dependency 'lp', '~> 0.2.0' From 07c4b588076403bff7d9aa73bfe2564eabcc7a0b Mon Sep 17 00:00:00 2001 From: meleu Date: Mon, 14 Apr 2025 15:32:23 -0300 Subject: [PATCH 3/8] Prevent running validate_* functions twice --- lib/bashly/views/flag/validations.gtx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/bashly/views/flag/validations.gtx b/lib/bashly/views/flag/validations.gtx index 8f92f26e..43b0628a 100644 --- a/lib/bashly/views/flag/validations.gtx +++ b/lib/bashly/views/flag/validations.gtx @@ -6,16 +6,20 @@ if validate > values='' > eval "values=(${args['{{ long }}']})" > for value in "${values[@]}"; do - > if [[ -n $(validate_{{ validate }} "$value") ]]; then - > printf "{{ strings[:validation_error] }}\n" "{{ usage_string }}" "$(validate_{{ validate }} "$value")" >&2 + > validation_output="$(validate_{{ validate }} "$value")" + > if [[ -n "$validation_output" ]]; then + > printf "{{ strings[:validation_error] }}\n" "{{ usage_string }}" "$validation_output" >&2 > exit 1 > fi > done > fi else - > if [[ -v args['{{ long }}'] && -n $(validate_{{ validate }} "${args['{{ long }}']:-}") ]]; then - > printf "{{ strings[:validation_error] }}\n" "{{ usage_string }}" "$(validate_{{ validate }} "${args['{{ long }}']:-}")" >&2 - > exit 1 + > if [[ -v args['{{ long }}'] ]]; then + > validation_output="$(validate_{{ validate }} "${args['{{ long }}']:-}")" + > if [[ -n "${validation_output}" ]]; then + > printf "{{ strings[:validation_error] }}\n" "{{ usage_string }}" "$validation_output" >&2 + > exit 1 + > fi > fi > end From 0d21c9dcbe9b2bc81650b4c5499a8fb3f166a1c0 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Tue, 15 Apr 2025 07:26:18 +0000 Subject: [PATCH 4/8] spec artifacts --- examples/render-mandoc/README.md | 2 +- examples/render-mandoc/docs/download.1 | 2 +- examples/render-mandoc/docs/download.md | 2 +- spec/approvals/examples/render-mandoc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/render-mandoc/README.md b/examples/render-mandoc/README.md index a414d90b..4fed4809 100644 --- a/examples/render-mandoc/README.md +++ b/examples/render-mandoc/README.md @@ -102,7 +102,7 @@ ISSUE TRACKER AUTHORS Lana Lang. -Version 0.1.0 December 2024 download(1) +Version 0.1.0 April 2025 download(1) ```` diff --git a/examples/render-mandoc/docs/download.1 b/examples/render-mandoc/docs/download.1 index a801fc0d..0a04a10c 100644 --- a/examples/render-mandoc/docs/download.1 +++ b/examples/render-mandoc/docs/download.1 @@ -1,6 +1,6 @@ .\" Automatically generated by Pandoc 3.2 .\" -.TH "download" "1" "March 2025" "Version 0.1.0" "Sample application" +.TH "download" "1" "April 2025" "Version 0.1.0" "Sample application" .SH NAME \f[B]download\f[R] \- Sample application .SH SYNOPSIS diff --git a/examples/render-mandoc/docs/download.md b/examples/render-mandoc/docs/download.md index 9d407154..c100ae82 100644 --- a/examples/render-mandoc/docs/download.md +++ b/examples/render-mandoc/docs/download.md @@ -1,6 +1,6 @@ % download(1) Version 0.1.0 | Sample application % Lana Lang -% March 2025 +% April 2025 NAME ================================================== diff --git a/spec/approvals/examples/render-mandoc b/spec/approvals/examples/render-mandoc index 738664d1..440f9b17 100644 --- a/spec/approvals/examples/render-mandoc +++ b/spec/approvals/examples/render-mandoc @@ -44,4 +44,4 @@ ISSUE TRACKER AUTHORS Lana Lang. -Version 0.1.0 March 2025 download(1) +Version 0.1.0 April 2025 download(1) From a4efccf82364858a9fc9480fad12de9588cff58e Mon Sep 17 00:00:00 2001 From: Vladimir Riabtsev Date: Fri, 18 Apr 2025 11:32:12 -0400 Subject: [PATCH 5/8] modified bashly to avoid conflict with run() function from another bash framework --- lib/bashly/views/command/master_script.gtx | 4 ++-- lib/bashly/views/command/run.gtx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/bashly/views/command/master_script.gtx b/lib/bashly/views/command/master_script.gtx index cae7faaf..56c2e591 100644 --- a/lib/bashly/views/command/master_script.gtx +++ b/lib/bashly/views/command/master_script.gtx @@ -16,10 +16,10 @@ if Settings.enabled? :sourcing > if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then > initialize - > run "$@" + > {{ function_name }}_run "$@" > fi else > initialize - > run "$@" + > {{ function_name }}_run "$@" end > diff --git a/lib/bashly/views/command/run.gtx b/lib/bashly/views/command/run.gtx index 975e49ed..7f8bef7c 100644 --- a/lib/bashly/views/command/run.gtx +++ b/lib/bashly/views/command/run.gtx @@ -1,6 +1,6 @@ = view_marker -> run() { +> {{ function_name }}_run() { = render(:globals).indent(2) > > normalize_input "$@" From 8fa881e2892958610feefd426fc8117e1fac88cd Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Sat, 19 Apr 2025 06:45:25 +0000 Subject: [PATCH 6/8] - Add settings for internal function names --- lib/bashly/libraries/settings/settings.yml | 5 +++++ lib/bashly/settings.rb | 9 +++++++++ lib/bashly/views/command/initialize.gtx | 2 +- lib/bashly/views/command/master_script.gtx | 8 ++++---- lib/bashly/views/command/run.gtx | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/bashly/libraries/settings/settings.yml b/lib/bashly/libraries/settings/settings.yml index 78176694..b6bc1ddd 100644 --- a/lib/bashly/libraries/settings/settings.yml +++ b/lib/bashly/libraries/settings/settings.yml @@ -126,3 +126,8 @@ var_aliases: other_args: ~ deps: ~ env_var_names: ~ + +# Choose different names for some of the internal functions. +function_names: + run: ~ + initialize: ~ diff --git a/lib/bashly/settings.rb b/lib/bashly/settings.rb index 389badcd..b59d5512 100644 --- a/lib/bashly/settings.rb +++ b/lib/bashly/settings.rb @@ -15,6 +15,7 @@ class << self :enable_inspect_args, :enable_sourcing, :enable_view_markers, + :function_names, :lib_dir, :partials_extension, :private_reveal_key, @@ -89,6 +90,14 @@ def full_lib_dir "#{source_dir}/#{lib_dir}" end + def function_name(key) + function_names[key.to_s] || key.to_s + end + + def function_names + @function_names ||= get :function_names + end + def lib_dir @lib_dir ||= get :lib_dir end diff --git a/lib/bashly/views/command/initialize.gtx b/lib/bashly/views/command/initialize.gtx index 272b0bc1..0b61fdec 100644 --- a/lib/bashly/views/command/initialize.gtx +++ b/lib/bashly/views/command/initialize.gtx @@ -1,6 +1,6 @@ = view_marker -> initialize() { +> {{ Settings.function_name :initialize }}() { > declare -g version="<%= version %>" > {{ Settings.strict_string }} diff --git a/lib/bashly/views/command/master_script.gtx b/lib/bashly/views/command/master_script.gtx index 56c2e591..bdfdbb78 100644 --- a/lib/bashly/views/command/master_script.gtx +++ b/lib/bashly/views/command/master_script.gtx @@ -15,11 +15,11 @@ > if Settings.enabled? :sourcing > if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then - > initialize - > {{ function_name }}_run "$@" + > {{ Settings.function_name :initialize }} + > {{ Settings.function_name :run }} "$@" > fi else - > initialize - > {{ function_name }}_run "$@" + > {{ Settings.function_name :initialize }} + > {{ Settings.function_name :run }} "$@" end > diff --git a/lib/bashly/views/command/run.gtx b/lib/bashly/views/command/run.gtx index 7f8bef7c..d4fbd802 100644 --- a/lib/bashly/views/command/run.gtx +++ b/lib/bashly/views/command/run.gtx @@ -1,6 +1,6 @@ = view_marker -> {{ function_name }}_run() { +> {{ Settings.function_name :run }}() { = render(:globals).indent(2) > > normalize_input "$@" From da384e03f2c049203ff3eae8c90c4d9ed6569392 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Tue, 22 Apr 2025 10:55:58 +0000 Subject: [PATCH 7/8] update settings json schema --- schemas/settings.json | 34 ++++++++++++++++++++++++++++++++++ support/schema/settings.yml | 21 +++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/schemas/settings.json b/schemas/settings.json index bf285f50..b52fb408 100644 --- a/schemas/settings.json +++ b/schemas/settings.json @@ -325,6 +325,40 @@ } }, "additionalProperties": false + }, + "function_names": { + "title": "function_names", + "description": "Choose different names for some of the internal functions.\nhttps://bashly.dev/usage/settings/#function_names", + "type": "object", + "properties": { + "run": { + "title": "run", + "description": "Name for the run() function\nhttps://bashly.dev/usage/settings/#function_names", + "oneOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ] + }, + "initialize": { + "title": "initialize", + "description": "Name for the initialize() function\nhttps://bashly.dev/usage/settings/#function_names", + "oneOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false } }, "additionalProperties": false diff --git a/support/schema/settings.yml b/support/schema/settings.yml index a9bfc7e5..8b4c4c17 100644 --- a/support/schema/settings.yml +++ b/support/schema/settings.yml @@ -265,4 +265,25 @@ properties: https://bashly.dev/usage/settings/#var_aliases oneOf: *optional_string additionalProperties: false + function_names: + title: function_names + description: |- + Choose different names for some of the internal functions. + https://bashly.dev/usage/settings/#function_names + type: object + properties: + run: + title: run + description: |- + Name for the run() function + https://bashly.dev/usage/settings/#function_names + oneOf: *optional_string + initialize: + title: initialize + description: |- + Name for the initialize() function + https://bashly.dev/usage/settings/#function_names + oneOf: *optional_string + additionalProperties: false + additionalProperties: false From a377e3170018f2ad6e21596a271900a774f44bc6 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Fri, 2 May 2025 07:08:40 +0000 Subject: [PATCH 8/8] version bump 1.2.12 --- Dockerfile | 2 +- examples/render-mandoc/docs/download.1 | 2 +- examples/render-mandoc/docs/download.md | 2 +- lib/bashly/version.rb | 2 +- spec/approvals/examples/render-mandoc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 462de257..3e40b5df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM dannyben/alpine-ruby:3.3.3 LABEL io.whalebrew.name=bashly ENV PS1="\n\n>> bashly \W \$ " -ENV BASHLY_VERSION=1.2.11 +ENV BASHLY_VERSION=1.2.12 WORKDIR /app diff --git a/examples/render-mandoc/docs/download.1 b/examples/render-mandoc/docs/download.1 index 0a04a10c..6874ec76 100644 --- a/examples/render-mandoc/docs/download.1 +++ b/examples/render-mandoc/docs/download.1 @@ -1,6 +1,6 @@ .\" Automatically generated by Pandoc 3.2 .\" -.TH "download" "1" "April 2025" "Version 0.1.0" "Sample application" +.TH "download" "1" "May 2025" "Version 0.1.0" "Sample application" .SH NAME \f[B]download\f[R] \- Sample application .SH SYNOPSIS diff --git a/examples/render-mandoc/docs/download.md b/examples/render-mandoc/docs/download.md index c100ae82..4af5ccaa 100644 --- a/examples/render-mandoc/docs/download.md +++ b/examples/render-mandoc/docs/download.md @@ -1,6 +1,6 @@ % download(1) Version 0.1.0 | Sample application % Lana Lang -% April 2025 +% May 2025 NAME ================================================== diff --git a/lib/bashly/version.rb b/lib/bashly/version.rb index 1727471a..c8ad4957 100644 --- a/lib/bashly/version.rb +++ b/lib/bashly/version.rb @@ -1,3 +1,3 @@ module Bashly - VERSION = '1.2.11' + VERSION = '1.2.12' end diff --git a/spec/approvals/examples/render-mandoc b/spec/approvals/examples/render-mandoc index 440f9b17..9e865953 100644 --- a/spec/approvals/examples/render-mandoc +++ b/spec/approvals/examples/render-mandoc @@ -44,4 +44,4 @@ ISSUE TRACKER AUTHORS Lana Lang. -Version 0.1.0 April 2025 download(1) +Version 0.1.0 May 2025 download(1)