clactive 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/clactive.rb +15 -10
- 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: 2807221f858d1a13f24c600df346ab12e4364b6f
|
4
|
+
data.tar.gz: aa5c10a9e6db92bf2a0ef42e1db8f9a41f862cf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80671a97c54c39b6634b2c0ee45521a57d95165355277cccc74955cd6c6f13c12906dd908618b634342325292d428cfe02dbbb092c0ec56d47aa65ee44cb73c5
|
7
|
+
data.tar.gz: 93913244e093331057cb52e7c16501c063ecfccbc5702594680c61f10f9b8c23ef0b1a12a20d63d8c2f963fb137ed65730a4f388a90b1a69dd21a2713b936013
|
data/lib/clactive.rb
CHANGED
@@ -37,24 +37,27 @@ module CLActive
|
|
37
37
|
|
38
38
|
klass_subcmd = Class.new do
|
39
39
|
define_method :initialize do
|
40
|
-
@options = {}.extend(tos)
|
41
40
|
@subcmds = {}.extend(tos)
|
42
41
|
@usropts = {}.extend(tos)
|
42
|
+
@parser = OptionParser.new
|
43
43
|
end
|
44
44
|
|
45
45
|
def parse(args)
|
46
|
-
|
47
|
-
@options.each do |key, argv|
|
48
|
-
opt.on(*argv) do |val|
|
49
|
-
@usropts[key] = val
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end.order!(args)
|
46
|
+
@parser.order!(args)
|
53
47
|
@subcmds
|
54
48
|
end
|
55
49
|
|
50
|
+
def help
|
51
|
+
puts @parser.help
|
52
|
+
end
|
53
|
+
|
56
54
|
def run
|
57
|
-
|
55
|
+
if @action
|
56
|
+
argv = [@usropts]
|
57
|
+
argc = @action.arity
|
58
|
+
argv << self if argc > 1 || argc < 0
|
59
|
+
@action.call(*argv)
|
60
|
+
end
|
58
61
|
end
|
59
62
|
|
60
63
|
def subcmd(name)
|
@@ -66,7 +69,9 @@ module CLActive
|
|
66
69
|
end
|
67
70
|
|
68
71
|
def option(name, *argv)
|
69
|
-
@
|
72
|
+
@parser.on(*argv) do |val|
|
73
|
+
@usropts[name] = val
|
74
|
+
end
|
70
75
|
self
|
71
76
|
end
|
72
77
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tang Tianyong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: CLActive help you to build command quickly
|
14
14
|
email: tang3w@gmail.com
|