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 +4 -4
- data/lib/bashly/config_validator.rb +20 -0
- data/lib/bashly/docs/flag.yml +15 -3
- data/lib/bashly/script/argument.rb +1 -1
- data/lib/bashly/script/flag.rb +1 -1
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/parse_requirements_case_repeatable.gtx +11 -3
- data/lib/bashly/views/flag/case_arg.gtx +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d7c552cf8d73f90e7dbeb030acef7a6b329db3b0cd48e9436845c900aa26c03
|
4
|
+
data.tar.gz: 5bfb9b67eab6bec13a43b97967822eee9fa6f24c0faf013d36e4670ab747f48a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/bashly/docs/flag.yml
CHANGED
@@ -41,9 +41,10 @@ flag.arg:
|
|
41
41
|
url: https://bashly.dannyb.co/configuration/flag/#arg
|
42
42
|
example: |-
|
43
43
|
flags:
|
44
|
-
- long: --
|
45
|
-
short: -
|
46
|
-
|
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
|
|
data/lib/bashly/script/flag.rb
CHANGED
data/lib/bashly/version.rb
CHANGED
@@ -7,9 +7,17 @@ args.each do |arg|
|
|
7
7
|
if arg.repeatable
|
8
8
|
> args['{{ arg.name }}']="\"$1\""
|
9
9
|
> shift
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
10
|
-
|
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.
|
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
|
+
date: 2023-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|