bashly 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17cea196efbe1bc65a6639258fe902503b75656c6a759ea5434a12d6a53d4529
4
- data.tar.gz: 5e86d08e594250889bc351d5d6113bcfc40f8ec04ba39f72a7f19eec8329c7af
3
+ metadata.gz: 0a7e677e8b16a4711ece6638e16e585b1bf74fca12cc6c3e9ea4810c209d4693
4
+ data.tar.gz: 630667bb3c3d36055a0160f05719a9561d8ec7cdbd02af80fd9c2a7a5edabd17
5
5
  SHA512:
6
- metadata.gz: ade5312408fc08533dc6992673744920e941e142c09c9f05e58e66a08a6dfccfab100707cee319cb2ec388e60f9a73ae8ff735e8217c8f91820fc5e2e22af886
7
- data.tar.gz: cf7f6da0438551ba2a10ed5c224d7ad6ac6b02d8675dca57c8ac01eb465e705a19bd2c3d1812b61b54ab52a433b5ce228b7f3b579e9de24f71c6f512caad1202
6
+ metadata.gz: 7dd08f97c66d81979c68b43d356b650ec50d30b0c2d0d8663388f0fec56f881bd5b140a55719143e00d155b2f0ae321d6207bf63c7e248d324489cf7dc3b7cee
7
+ data.tar.gz: 754c2b4aaa9e289b04e83e10b861933b26ef3168620315a7a9655c8dc991c095d0e42037a43d379b2d1f86d6f4eb5a6e3d6ea70009642d873e7dafb1627cfffa
data/README.md CHANGED
@@ -27,15 +27,6 @@ usually handled by a framework in any other programming language.
27
27
  It is available both as a [ruby gem](https://rubygems.org/gems/bashly) and as
28
28
  a [docker image](https://hub.docker.com/r/dannyben/bashly).
29
29
 
30
- ## Bashly is Sponsored By
31
-
32
- <table>
33
- <tr>
34
- <td><a href="https://rhodecode.com/"><img src='support/img/RhodeCode-logo.png' width=240></a></td>
35
- </tr>
36
- </table>
37
-
38
-
39
30
  ## Documentation
40
31
 
41
32
  - [Bashly Homepage][docs]
@@ -16,8 +16,8 @@ module Bashly
16
16
  option '-e --env ENV', <<~HELP
17
17
  Force the generation environment:
18
18
 
19
- - production generate a smaller script, without file markers
20
- - development generate with file markers
19
+ - development default script output
20
+ - production remove file marker comments and development functions
21
21
  HELP
22
22
 
23
23
  example 'bashly generate --force'
@@ -1,4 +1,4 @@
1
- # approvals.bash v0.4.0
1
+ # approvals.bash v0.4.2
2
2
  #
3
3
  # Interactive approval testing for Bash.
4
4
  # https://github.com/DannyBen/approvals.bash
@@ -9,8 +9,8 @@ approve() {
9
9
  cmd=$1
10
10
  last_exit_code=0
11
11
  actual=$(eval "$cmd" 2>&1) || last_exit_code=$?
12
- if [[ "$allow_diff_regex" ]]; then
13
- actual=$(echo "$actual" | sed "s/$allow_diff_regex/*/g")
12
+ if [[ -v allow_diff_regex && "$allow_diff_regex" ]]; then
13
+ actual=$(echo "$actual" | sed -E "s/$allow_diff_regex/*/g")
14
14
  unset allow_diff_regex
15
15
  fi
16
16
  approval=$(printf "%b" "$cmd" | tr -s -c "[:alnum:]" _)
@@ -322,6 +322,11 @@ module Bashly
322
322
  @user_lib ||= Dir["#{Settings.full_lib_dir}/**/*.#{Settings.partials_extension}"]
323
323
  end
324
324
 
325
+ # Returns a mixed array of Argument and Flag objects that have validations
326
+ def validatables
327
+ @validatables ||= args.select(&:validate) + flags.select(&:validate)
328
+ end
329
+
325
330
  # Returns an array of all the args with a whitelist
326
331
  def whitelisted_args
327
332
  args.select(&:allowed)
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = '1.1.5'
2
+ VERSION = '1.1.7'
3
3
  end
@@ -1,11 +1,22 @@
1
1
  if validate
2
+ = view_marker
2
3
 
3
- = view_marker
4
-
5
- > if [[ -n $(validate_{{ validate }} "$1") ]]; then
6
- > printf "{{ strings[:validation_error] }}\n" "{{ name.upcase }}" "$(validate_{{ validate }} "$1")" >&2
7
- > exit 1
8
- > fi
9
- >
4
+ if repeatable
5
+ > if [[ -v args['{{ name }}'] ]]; then
6
+ > eval "values=(${args['{{ name }}']})"
7
+ > for value in "${values[@]}"; do
8
+ > if [[ -n $(validate_{{ validate }} "$value") ]]; then
9
+ > printf "{{ strings[:validation_error] }}\n" "{{ name.upcase }}" "$(validate_{{ validate }} "$value")" >&2
10
+ > exit 1
11
+ > fi
12
+ > done
13
+ > fi
14
+ else
15
+ > if [[ -v args['{{ name }}'] && -n $(validate_{{ validate }} "${args['{{ name }}']:-}") ]]; then
16
+ > printf "{{ strings[:validation_error] }}\n" "{{ name.upcase }}" "$(validate_{{ validate }} "${args['{{ name }}']:-}")" >&2
17
+ > exit 1
18
+ > fi
19
+ >
20
+ end
10
21
 
11
22
  end
@@ -4,7 +4,7 @@
4
4
  = render :version_command
5
5
  = render :usage
6
6
  = render :normalize_input
7
- = render :inspect_args
7
+ = render :inspect_args unless Settings.production?
8
8
  = render :user_lib if user_lib.any?
9
9
  = render :command_functions
10
10
  = render :parse_requirements
@@ -15,6 +15,7 @@ end
15
15
  = render(:required_flags_filter).indent 2
16
16
  = render(:catch_all_filter).indent 2
17
17
  = render(:default_assignments).indent 2
18
+ = render(:validations).indent 2
18
19
  = render(:whitelist_filter).indent 2
19
20
  = render(:user_filter).indent 2
20
21
 
@@ -4,7 +4,6 @@ if args.any?
4
4
  condition = "if"
5
5
  args.each do |arg|
6
6
  > {{ condition }} [[ -z ${args['{{ arg.name }}']+x} ]]; then
7
- = arg.render(:validations).indent 2
8
7
  > args['{{ arg.name }}']=$1
9
8
  > shift
10
9
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  condition = "if"
4
4
  args.each do |arg|
5
- = arg.render(:validations)
6
5
  > {{ condition }} [[ -z ${args['{{ arg.name }}']+x} ]]; then
7
6
  if arg.repeatable
8
7
  > args['{{ arg.name }}']="\"$1\""
@@ -4,7 +4,6 @@ if args.any?
4
4
  condition = "if"
5
5
  args.each do |arg|
6
6
  > {{ condition }} [[ -z ${args['{{ arg.name }}']+x} ]]; then
7
- > {{ arg.render(:validations).indent 2 }}
8
7
  > args['{{ arg.name }}']=$1
9
8
  > shift
10
9
 
@@ -0,0 +1,7 @@
1
+ if validatables.any?
2
+ = view_marker
3
+
4
+ validatables.each do |arg_or_flag|
5
+ = arg_or_flag.render(:validations)
6
+ end
7
+ end
@@ -1,7 +1,6 @@
1
1
  = view_marker
2
2
 
3
3
  > if [[ -n ${2+x} ]]; then
4
- = render(:validations).indent 2
5
4
 
6
5
  if repeatable
7
6
  > if [[ -z ${args['{{ name }}']+x} ]]; then
@@ -1,11 +1,22 @@
1
1
  if validate
2
-
3
2
  = view_marker
4
3
 
5
- > if [[ -n $(validate_{{ validate }} "$2") ]]; then
6
- > printf "{{ strings[:validation_error] }}\n" "{{ usage_string }}" "$(validate_{{ validate }} "$2")" >&2
7
- > exit 1
8
- > fi
9
- >
4
+ if repeatable
5
+ > if [[ -v args['{{ long }}'] ]]; then
6
+ > eval "values=(${args['{{ long }}']})"
7
+ > for value in "${values[@]}"; do
8
+ > if [[ -n $(validate_{{ validate }} "$value") ]]; then
9
+ > printf "{{ strings[:validation_error] }}\n" "{{ usage_string }}" "$(validate_{{ validate }} "$value")" >&2
10
+ > exit 1
11
+ > fi
12
+ > done
13
+ > fi
14
+ else
15
+ > if [[ -v args['{{ long }}'] && -n $(validate_{{ validate }} "${args['{{ long }}']:-}") ]]; then
16
+ > printf "{{ strings[:validation_error] }}\n" "{{ usage_string }}" "$(validate_{{ validate }} "${args['{{ long }}']:-}")" >&2
17
+ > exit 1
18
+ > fi
19
+ >
20
+ end
10
21
 
11
22
  end
data/lib/bashly.rb CHANGED
@@ -1,5 +1,5 @@
1
- if ENV['BYEBUG']
2
- require 'byebug'
1
+ if ENV['DEBUGGER']
2
+ require 'debug'
3
3
  require 'lp'
4
4
  end
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bashly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-22 00:00:00.000000000 Z
11
+ date: 2024-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -265,6 +265,7 @@ files:
265
265
  - lib/bashly/views/command/user_filter.gtx
266
266
  - lib/bashly/views/command/user_hooks.gtx
267
267
  - lib/bashly/views/command/user_lib.gtx
268
+ - lib/bashly/views/command/validations.gtx
268
269
  - lib/bashly/views/command/version_command.gtx
269
270
  - lib/bashly/views/command/whitelist_filter.gtx
270
271
  - lib/bashly/views/environment_variable/usage.gtx
@@ -301,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
302
  - !ruby/object:Gem::Version
302
303
  version: '0'
303
304
  requirements: []
304
- rubygems_version: 3.3.26
305
+ rubygems_version: 3.5.6
305
306
  signing_key:
306
307
  specification_version: 4
307
308
  summary: Bash Command Line Tool Generator