lab42_options 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -1
- data/lib/lab42/options/forwarder.rb +2 -0
- data/lib/lab42/options/parser.rb +8 -3
- data/lib/lab42/options/version.rb +1 -1
- 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: fc16f86cc55f71e19a7c41cd024131a53e2968db
|
4
|
+
data.tar.gz: 47887a14848a7d6c666f48a1d908c93577e152f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 777cf27a5727f4ce0484f72c3e2364a697b47732e748b2d6d1e6960305d4e237afeecdff4c500a4ee8ba420084a1842d6ef1d55d4868c4e4635f41212b556e25
|
7
|
+
data.tar.gz: e9f5f84c8b68bcc8cd44dbd9efd24517a198af1c6057f562df62ee34dff0571dc5f2bd3e2296cfadf9643d8637732612725924c091e54e972dc02eb1ca6ff257
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
Lets us specify command line options with the same syntax as ruby parameters
|
6
6
|
|
7
7
|
```
|
8
|
-
my_shiny_gem "hello"
|
8
|
+
my_shiny_gem "hello" "world" :verbose answer: 42
|
9
9
|
```
|
10
10
|
|
11
11
|
Will yield
|
@@ -21,3 +21,36 @@ Will yield
|
|
21
21
|
options[:answer] # --> "42"
|
22
22
|
options.answer # --> "42"
|
23
23
|
```
|
24
|
+
|
25
|
+
## Multiple values
|
26
|
+
|
27
|
+
When providing the same key many times the options object will become an array
|
28
|
+
|
29
|
+
```
|
30
|
+
my_even_shiner_gem 42 tag: cool :mixed tag: hot mixed: pickels
|
31
|
+
```
|
32
|
+
|
33
|
+
Will yield
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
|
37
|
+
options.args # --> %W{42}
|
38
|
+
options[:tag] # --> %W{cool hot}
|
39
|
+
options.mixed # --> [true, "pickels"]
|
40
|
+
```
|
41
|
+
|
42
|
+
## Missing Features
|
43
|
+
|
44
|
+
* Help Message Generation
|
45
|
+
|
46
|
+
https://github.com/RobertDober/lab42_options/issues/3
|
47
|
+
|
48
|
+
* Required Arguments
|
49
|
+
|
50
|
+
https://github.com/RobertDober/lab42_options/issues/2
|
51
|
+
|
52
|
+
* Default Arguments
|
53
|
+
|
54
|
+
https://github.com/RobertDober/lab42_options/issues/2
|
55
|
+
|
56
|
+
* Typed Arguments
|
data/lib/lab42/options/parser.rb
CHANGED
@@ -16,15 +16,20 @@ module Lab42
|
|
16
16
|
loop do
|
17
17
|
case current = e.next
|
18
18
|
when /\A:(.*)/
|
19
|
-
|
19
|
+
update_value $1.to_sym, true
|
20
20
|
when /\A(.*):\z/
|
21
|
-
|
21
|
+
update_value $1.to_sym, e.next
|
22
22
|
else
|
23
23
|
positionals << current
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
|
+
def update_value key, val
|
29
|
+
kwds.merge! key => val do |k, oldv, newv|
|
30
|
+
Array( oldv ) << newv
|
31
|
+
end
|
32
|
+
end
|
28
33
|
end
|
29
34
|
end
|
30
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab42_options
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|