bashly 1.1.3 → 1.1.4

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: 44036d2bc4aabc216e7d60a788bfce201f71ad8230f4b44df5cb9d201500a0a5
4
- data.tar.gz: 30a1fb4efdafb7c305f0b1f1dcb38eaf8e05ed4a613b73c2ebd501cfe319bde7
3
+ metadata.gz: 8d7c552cf8d73f90e7dbeb030acef7a6b329db3b0cd48e9436845c900aa26c03
4
+ data.tar.gz: 5bfb9b67eab6bec13a43b97967822eee9fa6f24c0faf013d36e4670ab747f48a
5
5
  SHA512:
6
- metadata.gz: 78109f5a7b1273746d0db4dfcce037862ee9964333c001b4db5bec3997074ec70aab849e7783c12cf1337b4c5086747e8591c94ed9d52e612bf1e281cdfff772
7
- data.tar.gz: 141f6ad7bf8a1a932f8d76774737dde4ef61f7222adc48c3932eba460d187dde4a194e9ee5771b3136bd699410e50874ecaa2f668a51684662c506f33013820c
6
+ metadata.gz: 6b00ae3f396edb6550a49d950cbb18c3a02ea7c972dcb3e3be9fe964c9185c53ae33924870f27a3f12b235dc7390d0b95f1ef66036f7ed2e1cb34d6796091937
7
+ data.tar.gz: d12b41db4937a0267615a54cfe8c7b6062c798e83c48261a74cc3d88678e7046d81fd35ae0f0c1e5481f9754347dce9f95871bb37f61b379d8da022f572c5227
@@ -95,12 +95,17 @@ module Bashly
95
95
  assert_optional_string "#{key}.validate", value['validate']
96
96
  assert_boolean "#{key}.required", value['required']
97
97
  assert_boolean "#{key}.repeatable", value['repeatable']
98
+ assert_boolean "#{key}.unique", value['unique']
98
99
 
99
100
  assert_array "#{key}.allowed", value['allowed'], of: :string
100
101
 
101
102
  refute value['name'].match(/^-/), "#{key}.name must not start with '-'"
102
103
 
103
104
  refute value['required'] && value['default'], "#{key} cannot have both nub`required` and nub`default`"
105
+
106
+ if value['unique']
107
+ assert value['repeatable'], "#{key}.unique does not make sense without nub`repeatable`"
108
+ end
104
109
  end
105
110
 
106
111
  def assert_flag(key, value)
@@ -118,6 +123,7 @@ module Bashly
118
123
 
119
124
  assert_boolean "#{key}.private", value['private']
120
125
  assert_boolean "#{key}.repeatable", value['repeatable']
126
+ assert_boolean "#{key}.unique", value['unique']
121
127
  assert_boolean "#{key}.required", value['required']
122
128
  assert_array "#{key}.allowed", value['allowed'], of: :string
123
129
  assert_array "#{key}.conflicts", value['conflicts'], of: :string
@@ -140,6 +146,10 @@ module Bashly
140
146
  if value['completions']
141
147
  assert value['arg'], "#{key}.completions does not make sense without nub`arg`"
142
148
  end
149
+
150
+ if value['unique']
151
+ assert value['arg'] && value['repeatable'], "#{key}.unique does not make sense without nub`arg` and nub`repeatable`"
152
+ end
143
153
  end
144
154
 
145
155
  def assert_env_var(key, value)
@@ -201,6 +211,16 @@ module Bashly
201
211
  refute repeatable_arg, "#{key}.catch_all makes no sense with repeatable arg (#{repeatable_arg})"
202
212
  end
203
213
 
214
+ if value['args']
215
+ repeatable_args = value['args'].count { |a| a['repeatable'] }
216
+ assert repeatable_args < 2, "#{key}.args cannot have more than one repeatable args"
217
+
218
+ if repeatable_args == 1
219
+ assert value['args'].last['repeatable'],
220
+ "#{key}.args cannot contain a repeatable arg unless it is the last one"
221
+ end
222
+ end
223
+
204
224
  if value['expose']
205
225
  assert value['commands'], "#{key}.expose makes no sense without nub`commands`"
206
226
  end
@@ -41,9 +41,10 @@ flag.arg:
41
41
  url: https://bashly.dannyb.co/configuration/flag/#arg
42
42
  example: |-
43
43
  flags:
44
- - long: --ssh
45
- short: -s
46
- help: Clone using SSH
44
+ - long: --user
45
+ short: -u
46
+ arg: name
47
+ help: Specify the user name
47
48
 
48
49
  flag.completions:
49
50
  help: Specify a list of additional completion suggestions when used in conjunction with `bashly add completions`. Must be accompanied by `arg`.
@@ -161,6 +162,17 @@ flag.short:
161
162
  arg: name
162
163
  help: Repository user name
163
164
 
165
+ flag.unique:
166
+ help: Specify that the arguments provided by this repeatable flag must be unique. When this is set to `true`, non-unique values will be ignored.
167
+ url: https://bashly.dannyb.co/configuration/flag/#unique
168
+ example: |-
169
+ flags:
170
+ - long: --path
171
+ arg: location
172
+ help: Set one or more paths
173
+ repeatable: true
174
+ unique: true
175
+
164
176
  flag.validate:
165
177
  help: Apply custom validation functions. Must be accompanied by `arg`.
166
178
 
@@ -4,7 +4,7 @@ module Bashly
4
4
  class << self
5
5
  def option_keys
6
6
  @option_keys ||= %i[
7
- allowed default help name repeatable required validate
7
+ allowed default help name repeatable required unique validate
8
8
  ]
9
9
  end
10
10
  end
@@ -7,7 +7,7 @@ module Bashly
7
7
  def option_keys
8
8
  @option_keys ||= %i[
9
9
  allowed arg completions conflicts default help long repeatable
10
- required short validate private
10
+ required short unique validate private
11
11
  ]
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module Bashly
2
- VERSION = '1.1.3'
2
+ VERSION = '1.1.4'
3
3
  end
@@ -7,9 +7,17 @@ args.each do |arg|
7
7
  if arg.repeatable
8
8
  > args['{{ arg.name }}']="\"$1\""
9
9
  > shift
10
- > else
11
- > args['{{ arg.name }}']="${args[{{ arg.name }}]} \"$1\""
12
- > shift
10
+ if arg.unique
11
+ > elif [[ ! "${args['{{ arg.name }}']}" =~ \"$1\" ]]; then
12
+ > args['{{ arg.name }}']="${args[{{ arg.name }}]} \"$1\""
13
+ > shift
14
+ > else
15
+ > shift
16
+ else
17
+ > else
18
+ > args['{{ arg.name }}']="${args[{{ arg.name }}]} \"$1\""
19
+ > shift
20
+ end
13
21
 
14
22
  else
15
23
  > args['{{ arg.name }}']=$1
@@ -6,8 +6,12 @@
6
6
  if repeatable
7
7
  > if [[ -z ${args['{{ name }}']+x} ]]; then
8
8
  > args['{{ name }}']="\"$2\""
9
- > else
10
- > args['{{ name }}']="${args[{{ name }}]} \"$2\""
9
+ if unique
10
+ > elif [[ ! "${args['{{ name }}']}" =~ \"$2\" ]]; then
11
+ else
12
+ > else
13
+ end
14
+ > args['{{ name }}']="${args['{{ name }}']} \"$2\""
11
15
  > fi
12
16
 
13
17
  else
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.3
4
+ version: 1.1.4
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-11-25 00:00:00.000000000 Z
11
+ date: 2023-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole