clint 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/clint.rb +10 -0
- metadata +3 -3
data/lib/clint.rb
CHANGED
@@ -125,11 +125,18 @@ class Clint
|
|
125
125
|
# subcommand is sent to the instance with the remaining non-option
|
126
126
|
# arguments.
|
127
127
|
def subcommand(klass)
|
128
|
+
|
129
|
+
# Find the subcommand.
|
128
130
|
if 1 > @args.length
|
129
131
|
usage
|
130
132
|
exit 1
|
131
133
|
end
|
132
134
|
subcommand = @args.shift.to_sym
|
135
|
+
|
136
|
+
# Give the caller the opportunity to declare more options.
|
137
|
+
yield subcommand if block_given?
|
138
|
+
|
139
|
+
# Execute the subcommand as a class method.
|
133
140
|
if klass.singleton_methods(false).include? subcommand.to_s
|
134
141
|
arity = klass.method(subcommand).arity
|
135
142
|
if @args.length != arity && -@args.length - 1 != arity
|
@@ -143,6 +150,8 @@ class Clint
|
|
143
150
|
end
|
144
151
|
exit 0
|
145
152
|
end
|
153
|
+
|
154
|
+
# Execute the subcommand as an instance method.
|
146
155
|
if 1 > @args.length
|
147
156
|
usage
|
148
157
|
exit 1
|
@@ -161,6 +170,7 @@ class Clint
|
|
161
170
|
end
|
162
171
|
exit 0
|
163
172
|
end
|
173
|
+
|
164
174
|
end
|
165
175
|
|
166
176
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Richard Crowley
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-02-
|
17
|
+
date: 2010-02-23 00:00:00 +00:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|