clint 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/clint.rb +10 -0
  2. metadata +3 -3
@@ -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
- - 0
9
- version: 0.1.0
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-22 00:00:00 +00:00
17
+ date: 2010-02-23 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies: []
20
20