bashly 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 412b8737b7f30c9851116b020bafbb220bb001fcf148d4baf3bc383a32ad3e0d
4
- data.tar.gz: 0b4595b01191d2899f50ab7d74f6f7f9d0ec4901f17daebf57304d197b8e8ccd
3
+ metadata.gz: 0a7e677e8b16a4711ece6638e16e585b1bf74fca12cc6c3e9ea4810c209d4693
4
+ data.tar.gz: 630667bb3c3d36055a0160f05719a9561d8ec7cdbd02af80fd9c2a7a5edabd17
5
5
  SHA512:
6
- metadata.gz: 9af37fd9a1a5883e8c05ff88d3fd1de2b0689586e9717072b17e15dcb55a9c8f228e963e2131aa8828a1fd1d12a51c8373bdf28f650f8e13369dcf84bec3a68a
7
- data.tar.gz: 51a9db127eb74ebbe7e3d55aa8fb6e7f17479c587e632061d62330503103dbed7ca7c405f01d3090036459aaf5a529960156c66d6248849f936aff5be0bcd6d7
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]
@@ -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.6'
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
@@ -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.6
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-29 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