clactive 0.0.11 → 0.0.12
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 +23 -3
- 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: c7e4c4ba93357a7c358eadf5cbbe467a0763d50c
|
4
|
+
data.tar.gz: e516a1c1bf8f1de50a02137849a5882a4bc61831
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e78465a5aeb0b5065f6292110bcd4853f3c9557f13c1632d99dcfccc9051c8976faf7751611ec3cc8b62450fb056cd90433caef8d0b9cb27f889c4106e4e8e1
|
7
|
+
data.tar.gz: 81c3b49f88fdbfe22ddd15f7b64ecea4e60684709999abccef0b1d336a05ef01ed98fd1c2e6967c722d34d612ee523ca0f99e32f959a117a1eca98bdaa0463cb
|
data/lib/clactive.rb
CHANGED
@@ -77,13 +77,24 @@ module CLActive
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def [](key)
|
80
|
-
subcmds[key]
|
80
|
+
cmd = subcmds[key]
|
81
|
+
unless cmd
|
82
|
+
key = key.to_s
|
83
|
+
subcmds.reverse_each do |_, val|
|
84
|
+
return val if val.aka.include?(key)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
cmd
|
81
88
|
end
|
82
89
|
|
83
|
-
def subcmd(
|
90
|
+
def subcmd(*keys, &block)
|
84
91
|
if block
|
85
92
|
cmd = self.class.new
|
86
|
-
|
93
|
+
unless keys.empty?
|
94
|
+
keys.map!(&:to_s)
|
95
|
+
cmd.name(keys.shift)
|
96
|
+
cmd.aka.concat(keys) unless keys.empty?
|
97
|
+
end
|
87
98
|
cmd.instance_exec(&block)
|
88
99
|
subcmds[cmd.name] = cmd if cmd.name
|
89
100
|
else
|
@@ -111,6 +122,15 @@ module CLActive
|
|
111
122
|
def action(&block)
|
112
123
|
@action = block if block
|
113
124
|
end
|
125
|
+
|
126
|
+
def aka(key = nil)
|
127
|
+
if key
|
128
|
+
key = key.to_s
|
129
|
+
aka << key unless aka.include?(key)
|
130
|
+
else
|
131
|
+
@aka ||= []
|
132
|
+
end
|
133
|
+
end
|
114
134
|
end
|
115
135
|
|
116
136
|
apis = %w(name subcmd option action)
|
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.12
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: CLActive help you to build command quickly
|
14
14
|
email: tang3w@gmail.com
|