clive 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/clive.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{clive}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joshua Hawxwell"]
data/lib/clive/command.rb CHANGED
@@ -169,17 +169,11 @@ class Clive
169
169
  r << [:flag, flag]
170
170
  else
171
171
  if k == :word
172
- if r.last
173
- case r.last[0]
174
- when :flag
175
- if r.last[2]
176
- r << [:argument, v]
177
- else
178
- r.last[2] = v
179
- end
180
- else
181
- r << [:argument, v]
182
- end
172
+ # add to last flag?
173
+ if r.last && r.last[0] == :flag && r.last[2].nil?
174
+ r.last[2] = v
175
+ else
176
+ r << [:argument, v]
183
177
  end
184
178
  else
185
179
  raise InvalidOption.new(v)
data/test/bin_test CHANGED
@@ -48,6 +48,6 @@ c = Clive.new do
48
48
 
49
49
  end
50
50
 
51
- c.parse(ARGV)
51
+ p c.parse(ARGV)
52
52
  p options
53
53
 
data/test/test_clive.rb CHANGED
@@ -147,6 +147,21 @@ class TestClive < Test::Unit::TestCase
147
147
  assert_equal r, opts
148
148
  end
149
149
 
150
+ should "recognise an argument" do
151
+ c = Clive.new do
152
+ bool(:v, :verbose, "Run verbosely") {}
153
+ end
154
+ args = c.parse ["argument"]
155
+ assert_equal ["argument"], args
156
+ end
157
+
158
+ should "recognise multiple arguments" do
159
+ c = Clive.new do
160
+ bool(:v, :verbose, "Run verbosely") {}
161
+ end
162
+ args = c.parse ["argument", "and", "another"]
163
+ assert_equal ["argument", "and", "another"], args
164
+ end
150
165
 
151
166
  should "parse a mixture properly" do
152
167
  opts = {}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clive
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Hawxwell