optbind 0.5.0 → 0.5.1
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 +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +7 -3
- data/TODO.md +1 -0
- data/lib/optbind/default.rb +18 -4
- data/lib/optbind/handler.rb +2 -0
- data/lib/optbind/type.rb +1 -0
- data/lib/optbind/version.rb +1 -1
- data/lib/optbind.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e128bc6975c80a8f1261eca7bdf38743c2ad60ce
|
|
4
|
+
data.tar.gz: d4925a1d2d029ebbe05aba718f836b4b962b7494
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ae1e8391bec9d3225eccf45093af663de0fce4a23f4ec0b994544128c68623a83f5d4d66b5b7135650aa3bb49980fbc56a77f5e592c43ebfa5bd6331076c1c0
|
|
7
|
+
data.tar.gz: b922fd19657c6be4def0a5f6357cf06df63a4b5985bdab264194c4dafb36dbaed35ee75ddf8a052c743ca3a4b8c2b1832aac220eb413b25918b0d3430724e19a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 0.5.0
|
|
2
|
+
|
|
3
|
+
* Support parsing of options with typed array value and multiple typed arguments
|
|
4
|
+
|
|
5
|
+
* Support underscore pattern syntax in string definitions
|
|
6
|
+
|
|
7
|
+
* Make parsing methods backwards compatible with `OptionParser` again
|
|
8
|
+
|
|
9
|
+
* Add extensions for parsing mode, known types, and custom handlers
|
|
10
|
+
|
|
11
|
+
* Add a lot of new test cases, minor bug fixes, and enhancements
|
|
12
|
+
|
|
13
|
+
*Pavol Zbell*
|
|
14
|
+
|
|
1
15
|
## 0.4.0
|
|
2
16
|
|
|
3
17
|
* Support binding options to class variables
|
data/README.md
CHANGED
|
@@ -265,7 +265,9 @@ Adds default values to option descriptions.
|
|
|
265
265
|
```ruby
|
|
266
266
|
require 'optbind/default'
|
|
267
267
|
|
|
268
|
+
# ...
|
|
268
269
|
|
|
270
|
+
print binder.help
|
|
269
271
|
```
|
|
270
272
|
|
|
271
273
|
#### Mode
|
|
@@ -275,7 +277,9 @@ Adds `order` and `permute` methods.
|
|
|
275
277
|
```ruby
|
|
276
278
|
require 'optbind/mode'
|
|
277
279
|
|
|
278
|
-
|
|
280
|
+
# ...
|
|
281
|
+
|
|
282
|
+
binder.order ARGV
|
|
279
283
|
```
|
|
280
284
|
|
|
281
285
|
Note that `order!` and `permute!` methods in `ARGV` from `OptionParser` are redefined to raise an unsupported error without this extension.
|
|
@@ -287,7 +291,7 @@ Adds various common types to accept in definitions.
|
|
|
287
291
|
```ruby
|
|
288
292
|
require 'optbind/type'
|
|
289
293
|
|
|
290
|
-
...
|
|
294
|
+
# ...
|
|
291
295
|
|
|
292
296
|
binder.option 'm --matcher=<pattern:Regexp>'
|
|
293
297
|
binder.option 'r --repository=<uri:URI>'
|
|
@@ -300,7 +304,7 @@ Adds various common handlers to accept in definitions.
|
|
|
300
304
|
```ruby
|
|
301
305
|
require 'optbind/handler'
|
|
302
306
|
|
|
303
|
-
...
|
|
307
|
+
# ...
|
|
304
308
|
|
|
305
309
|
binder.option 's --storage=<name>', &included_in(%w(file memory))
|
|
306
310
|
binder.option 'a --attachments=<ids>', &listed_as(Integer)
|
data/TODO.md
CHANGED
data/lib/optbind/default.rb
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require 'optbind'
|
|
2
|
+
|
|
3
|
+
class OptionBinder
|
|
4
|
+
alias_method :several_variants_without_default_description, :several_variants
|
|
5
|
+
|
|
6
|
+
def several_variants(*opts, &handler)
|
|
7
|
+
opts, handler, bound, variable, default = several_variants_without_default_description *opts, &handler
|
|
8
|
+
desc = opts.find { |o| o.is_a?(String) && o !~ /\A\s*[-=\[]/ }.tap { |d| opts.delete d if d }
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
if !default.nil? && (!default.respond_to?(:empty?) || !default.empty?)
|
|
11
|
+
desc = "#{desc == nil || desc.empty? ? 'D' : "#{desc}, d"}efault #{[default] * ','}"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
opts << desc if desc && !desc.empty?
|
|
15
|
+
return opts, handler, bound, variable, default
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private :several_variants
|
|
19
|
+
end
|
data/lib/optbind/handler.rb
CHANGED
data/lib/optbind/type.rb
CHANGED
data/lib/optbind/version.rb
CHANGED
data/lib/optbind.rb
CHANGED
|
@@ -61,7 +61,7 @@ class OptionBinder
|
|
|
61
61
|
def_delegator :@parser, :help
|
|
62
62
|
|
|
63
63
|
def usage(*args)
|
|
64
|
-
line = (args
|
|
64
|
+
line = (args * ' ') << "\n"
|
|
65
65
|
|
|
66
66
|
if @parser.banner =~ /\Ausage:.+\n\n/i
|
|
67
67
|
@parser.banner = "usage: #{program} #{line}"
|
|
@@ -152,7 +152,7 @@ class OptionBinder
|
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
argument = (hash[:argument].to_s.sub(/\A(\[)?=?/, '=\1') if hash[:argument])
|
|
155
|
-
description = ([hash[:description]]
|
|
155
|
+
description = ([hash[:description]] * ' ' if hash[:description])
|
|
156
156
|
handler ||= hash[:handler]
|
|
157
157
|
return (style + [pattern, values] + names + [argument, description]).compact, handler
|
|
158
158
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: optbind
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pavol Zbell
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-06-
|
|
11
|
+
date: 2016-06-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|