bashly 1.1.2 → 1.1.4

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: c90e3d5380ed91982c50ec46ff37c490e6b00785b80b75c60c4ddbb163902099
4
- data.tar.gz: b1777dac4776226205c27781cf86af045deed8f25a282e0e2a1a8fd3848e0115
3
+ metadata.gz: 8d7c552cf8d73f90e7dbeb030acef7a6b329db3b0cd48e9436845c900aa26c03
4
+ data.tar.gz: 5bfb9b67eab6bec13a43b97967822eee9fa6f24c0faf013d36e4670ab747f48a
5
5
  SHA512:
6
- metadata.gz: 24c19fb49d0cfe9a1ed96bfd0fa3d77973136ed2dfda747c11aa54244c30d2af17384f6aa4f7604c1a41562e41ffe9e5c1ad2a204a7dd85ac6e2d797c588d65b
7
- data.tar.gz: b2020a3dcf36073049511f4484d32542a5e54037a464c9e838c7a3ffb2fb48141223ea96ecf334aeb8b4609bedaeca3491d23901d02a481c5fb621354e695936
6
+ metadata.gz: 6b00ae3f396edb6550a49d950cbb18c3a02ea7c972dcb3e3be9fe964c9185c53ae33924870f27a3f12b235dc7390d0b95f1ef66036f7ed2e1cb34d6796091937
7
+ data.tar.gz: d12b41db4937a0267615a54cfe8c7b6062c798e83c48261a74cc3d88678e7046d81fd35ae0f0c1e5481f9754347dce9f95871bb37f61b379d8da022f572c5227
@@ -1,3 +1,5 @@
1
+ require 'completely'
2
+
1
3
  module Bashly
2
4
  module Commands
3
5
  class Completions < Base
@@ -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.2'
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.2
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-15 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