clactive 0.0.12 → 0.1.0
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 +4 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fbe801886dc426a98da5cf9dd0ebc68c5603e13
|
4
|
+
data.tar.gz: fe866941ea994017097781f587dfc8196ae68af3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c710cc74a92c7eb5979af5848f5ae3fdefc88d4635ef28f76b79a7fb35c26e9fe36f930875026fce65c56b5c1d80249cff524e4595fcfc872ce3bd6e25d69216
|
7
|
+
data.tar.gz: 04f3500abc11078523dc00d73f433437298b312fb69b08fed8e4898912fcf0aa2e8c4f31c6f93342099ebb0cb6597530c13d4f0ea98d8386f43ae63f2aac7650
|
data/lib/clactive.rb
CHANGED
@@ -12,8 +12,6 @@ module CLActive
|
|
12
12
|
end
|
13
13
|
|
14
14
|
parser = lambda do |cmd, args|
|
15
|
-
start = cmd
|
16
|
-
|
17
15
|
until args.empty?
|
18
16
|
begin
|
19
17
|
cmd.parse(args)
|
@@ -22,23 +20,24 @@ module CLActive
|
|
22
20
|
return
|
23
21
|
end
|
24
22
|
|
25
|
-
|
23
|
+
name = args.shift
|
24
|
+
break if !name || !cmd.usropts.empty?
|
26
25
|
|
27
26
|
unless subcmd = cmd[name]
|
28
27
|
puts "invalid option: " << name
|
29
28
|
return
|
30
29
|
end
|
31
30
|
|
32
|
-
cmd.subcmd = subcmd
|
33
31
|
cmd = subcmd
|
34
32
|
end
|
35
33
|
|
36
|
-
|
34
|
+
cmd.run
|
37
35
|
end
|
38
36
|
|
39
37
|
klass_subcmd = Class.new do
|
40
38
|
attr_reader :options
|
41
39
|
attr_reader :subcmds
|
40
|
+
attr_reader :usropts
|
42
41
|
|
43
42
|
define_method :initialize do
|
44
43
|
@options = {}.extend(tos)
|
@@ -68,14 +67,9 @@ module CLActive
|
|
68
67
|
argv = []
|
69
68
|
argv << @usropts if @action.arity != 0
|
70
69
|
self.instance_exec(*argv, &@action)
|
71
|
-
subcmd.run if subcmd
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
75
|
-
def subcmd=(cmd)
|
76
|
-
@subcmd = cmd
|
77
|
-
end
|
78
|
-
|
79
73
|
def [](key)
|
80
74
|
cmd = subcmds[key]
|
81
75
|
unless cmd
|
@@ -97,8 +91,6 @@ module CLActive
|
|
97
91
|
end
|
98
92
|
cmd.instance_exec(&block)
|
99
93
|
subcmds[cmd.name] = cmd if cmd.name
|
100
|
-
else
|
101
|
-
@subcmd
|
102
94
|
end
|
103
95
|
end
|
104
96
|
|
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.1.0
|
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-
|
11
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: CLActive help you to build command quickly
|
14
14
|
email: tang3w@gmail.com
|
@@ -17,7 +17,7 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/clactive.rb
|
20
|
-
homepage:
|
20
|
+
homepage: https://github.com/tang3w/CLActive
|
21
21
|
licenses:
|
22
22
|
- MIT
|
23
23
|
metadata: {}
|