cl 0.1.20 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cl/parser.rb +6 -9
- data/lib/cl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97d0963fc5570530e792aadfb50e842df447958c
|
4
|
+
data.tar.gz: 8b56cc03437ea8256189b989064ee6362d1c1f69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5a3938fe294a6b21a36c0ecf35691d7a597188083d3c31fc5423547b833b3415aea4535d131c870c9f5e8b4c5748dcf60755a9c23ee6018bac5452333b0fe92
|
7
|
+
data.tar.gz: ee6055bea2cd43fa21f413c35163016d0e3ce3690eb656be7cd70c334a3c6002d355050d43411eebea1dea19832bdea09ce87f794020813d247841ffdc176a4f
|
data/Gemfile.lock
CHANGED
data/lib/cl/parser.rb
CHANGED
@@ -9,25 +9,26 @@ class Cl
|
|
9
9
|
|
10
10
|
super do
|
11
11
|
opts.each do |opt|
|
12
|
-
on(*dasherize(opt.strs)) do |value|
|
12
|
+
on(*dasherize(*opt.strs)) do |value|
|
13
13
|
set(opt, value)
|
14
14
|
end
|
15
15
|
|
16
16
|
opt.aliases.each do |name|
|
17
|
-
on(aliased(opt, name)) do |value|
|
17
|
+
on(*dasherize(aliased(opt, name))) do |value|
|
18
18
|
@opts[name] = set(opt, value)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
dasherize
|
24
|
+
args.replace(dasherize(*args))
|
25
25
|
parse!(args)
|
26
26
|
end
|
27
27
|
|
28
28
|
def aliased(opt, name)
|
29
29
|
str = opt.strs.detect { |str| str.start_with?('--') } || raise
|
30
|
-
str.sub(opt.name.to_s, name.to_s)
|
30
|
+
str = str.sub(opt.name.to_s, name.to_s)
|
31
|
+
str.sub(opt.name.to_s.gsub('_', '-'), name.to_s)
|
31
32
|
end
|
32
33
|
|
33
34
|
# should consider negative arities (e.g. |one, *two|)
|
@@ -37,12 +38,8 @@ class Cl
|
|
37
38
|
instance_exec(*args, &opt.block)
|
38
39
|
end
|
39
40
|
|
40
|
-
def dasherize(strs)
|
41
|
+
def dasherize(*strs)
|
41
42
|
strs.map { |str| str.start_with?('--') ? str.gsub('_', '-') : str }
|
42
43
|
end
|
43
|
-
|
44
|
-
def dasherize!(strs)
|
45
|
-
strs.replace(dasherize(strs))
|
46
|
-
end
|
47
44
|
end
|
48
45
|
end
|
data/lib/cl/version.rb
CHANGED