commander 4.0.2 → 4.0.3
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.
- data/History.rdoc +5 -0
- data/commander.gemspec +3 -3
- data/lib/commander/runner.rb +11 -6
- data/lib/commander/version.rb +1 -1
- data/spec/runner_spec.rb +14 -1
- metadata +21 -9
data/History.rdoc
CHANGED
data/commander.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{commander}
|
5
|
-
s.version = "4.0.
|
5
|
+
s.version = "4.0.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["TJ Holowaychuk"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-04-06}
|
10
10
|
s.default_executable = %q{commander}
|
11
11
|
s.description = %q{The complete solution for Ruby command-line executables}
|
12
12
|
s.email = %q{tj@vision-media.ca}
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Commander", "--main", "README.rdoc"]
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
s.rubyforge_project = %q{commander}
|
20
|
-
s.rubygems_version = %q{1.3.
|
20
|
+
s.rubygems_version = %q{1.3.6}
|
21
21
|
s.summary = %q{The complete solution for Ruby command-line executables}
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
data/lib/commander/runner.rb
CHANGED
@@ -291,14 +291,19 @@ module Commander
|
|
291
291
|
def remove_global_options options, args
|
292
292
|
# TODO: refactor with flipflop, please TJ ! have time to refactor me !
|
293
293
|
options.each do |option|
|
294
|
-
switches = option[:switches]
|
294
|
+
switches = option[:switches].dup
|
295
|
+
next if switches.empty?
|
296
|
+
|
297
|
+
if switchHasArg = switches.any? { |s| s =~ /[ =]/ }
|
298
|
+
switches.map! { |s| s[0, s.index('=') || s.index(' ') || s.length] }
|
299
|
+
end
|
300
|
+
|
295
301
|
past_switch, arg_removed = false, false
|
296
302
|
args.delete_if do |arg|
|
297
|
-
|
298
|
-
|
299
|
-
past_switch
|
300
|
-
|
301
|
-
elsif past_switch && !arg_removed && arg !~ /^-/
|
303
|
+
if switches.any? { |s| arg[0, s.length] == s }
|
304
|
+
arg_removed = !switchHasArg
|
305
|
+
past_switch = true
|
306
|
+
elsif past_switch && !arg_removed && arg !~ /^-/
|
302
307
|
arg_removed = true
|
303
308
|
else
|
304
309
|
arg_removed = true
|
data/lib/commander/version.rb
CHANGED
data/spec/runner_spec.rb
CHANGED
@@ -112,7 +112,7 @@ describe Commander do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
describe "#remove_global_options" do
|
115
|
-
it "should
|
115
|
+
it "should remove only specified switches" do
|
116
116
|
options, args = [], []
|
117
117
|
options << { :switches => ['-t', '--trace'] }
|
118
118
|
options << { :switches => ['--help'] }
|
@@ -125,6 +125,19 @@ describe Commander do
|
|
125
125
|
command_runner.remove_global_options options, args
|
126
126
|
args.should == ['--command', '--command-with-arg', 'rawr']
|
127
127
|
end
|
128
|
+
|
129
|
+
it "should not swallow an argument unless it expects an argument" do
|
130
|
+
options, args = [], []
|
131
|
+
options << { :switches => ['-n', '--no-arg'] }
|
132
|
+
options << { :switches => ['-y', '--yes ARG'] }
|
133
|
+
options << { :switches => ['-a', '--alternative=ARG'] }
|
134
|
+
args << '-n' << 'alpha'
|
135
|
+
args << '--yes' << 'deleted'
|
136
|
+
args << '-a' << 'deleted'
|
137
|
+
args << 'beta'
|
138
|
+
command_runner.remove_global_options options, args
|
139
|
+
args.should == ['alpha', 'beta']
|
140
|
+
end
|
128
141
|
end
|
129
142
|
|
130
143
|
describe "--trace" do
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 4
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
version: 4.0.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- TJ Holowaychuk
|
@@ -9,19 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-04-06 00:00:00 -07:00
|
13
18
|
default_executable: commander
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: highline
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 5
|
30
|
+
- 0
|
23
31
|
version: 1.5.0
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
description: The complete solution for Ruby command-line executables
|
26
35
|
email: tj@vision-media.ca
|
27
36
|
executables:
|
@@ -108,18 +117,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
117
|
requirements:
|
109
118
|
- - ">="
|
110
119
|
- !ruby/object:Gem::Version
|
120
|
+
segments:
|
121
|
+
- 0
|
111
122
|
version: "0"
|
112
|
-
version:
|
113
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
124
|
requirements:
|
115
125
|
- - ">="
|
116
126
|
- !ruby/object:Gem::Version
|
127
|
+
segments:
|
128
|
+
- 1
|
129
|
+
- 2
|
117
130
|
version: "1.2"
|
118
|
-
version:
|
119
131
|
requirements: []
|
120
132
|
|
121
133
|
rubyforge_project: commander
|
122
|
-
rubygems_version: 1.3.
|
134
|
+
rubygems_version: 1.3.6
|
123
135
|
signing_key:
|
124
136
|
specification_version: 3
|
125
137
|
summary: The complete solution for Ruby command-line executables
|