commander 4.0.4 → 4.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/DEVELOPMENT +24 -0
- data/History.rdoc +11 -0
- data/Manifest +2 -0
- data/README.rdoc +30 -26
- data/Rakefile +22 -5
- data/commander.gemspec +20 -13
- data/lib/commander/platform.rb +1 -1
- data/lib/commander/runner.rb +13 -6
- data/lib/commander/user_interaction.rb +61 -1
- data/lib/commander/version.rb +1 -1
- data/spec/command_spec.rb +2 -3
- data/spec/core_ext/array_spec.rb +2 -3
- data/spec/core_ext/object_spec.rb +2 -3
- data/spec/help_formatters/terminal_spec.rb +2 -3
- data/spec/runner_spec.rb +133 -2
- data/spec/ui_spec.rb +1 -2
- data/tasks/dev_setup.rake +11 -0
- data/tasks/docs.rake +1 -0
- metadata +72 -6
data/DEVELOPMENT
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
To run the development rake tasks, you need rake and echoe gems installed.
|
2
|
+
|
3
|
+
To install the rest of the development dependencies:
|
4
|
+
|
5
|
+
$ rake dev_setup
|
6
|
+
|
7
|
+
Before you push any changes, run the RSpec suite:
|
8
|
+
|
9
|
+
$ rake spec
|
10
|
+
|
11
|
+
Build the docs:
|
12
|
+
|
13
|
+
$ rake docs
|
14
|
+
|
15
|
+
Build and check the docs:
|
16
|
+
|
17
|
+
$ rake docs:open
|
18
|
+
|
19
|
+
To build a new version of the gem:
|
20
|
+
|
21
|
+
$ rake build
|
22
|
+
$ rake gem
|
23
|
+
|
24
|
+
(NOTE: there currently seem to be some bugs in our development dependencies that prevent building the gem or docs on Ruby 1.9.2.)
|
data/History.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
4.0.5 / 2011-08-09
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Updated documentation to fix inaccuracies and unclear information.
|
5
|
+
* Improved rake tasks for gem development.
|
6
|
+
* Added say_ok, say_warning and say_error methods to print messages in green, yellow or red. (thanks to Simon Courtois)
|
7
|
+
* Fixed; Allow global options to be passed in any order, even mixed with command options. (thanks to Rich Grundy)
|
8
|
+
* Fixed; Global options can be passed before or after the command, they can even be mixed with command options. Closes #8. (thanks to Rich Grundy)
|
9
|
+
* Fixed; Platform test should now correctly identify JRuby. (thanks to Justin Lynn)
|
10
|
+
* Fixed; Add to_s to exceptions as option parser no longer does implicit conversion. (thanks to Justin Lynn)
|
11
|
+
|
1
12
|
4.0.4 / 2011-04-04
|
2
13
|
==================
|
3
14
|
|
data/Manifest
CHANGED
data/README.rdoc
CHANGED
@@ -26,8 +26,7 @@ features, and an elegant API.
|
|
26
26
|
|
27
27
|
== Installation
|
28
28
|
|
29
|
-
|
30
|
-
$ sudo gem install commander
|
29
|
+
$ gem install commander
|
31
30
|
|
32
31
|
== Example
|
33
32
|
|
@@ -99,8 +98,8 @@ are some quick examples for how to utilize highline in your command(s):
|
|
99
98
|
|
100
99
|
== HighLine & Interaction Additions
|
101
100
|
|
102
|
-
In addition to highline's fantastic choice of methods
|
103
|
-
simplify common tasks
|
101
|
+
In addition to highline's fantastic choice of methods, commander adds the
|
102
|
+
following methods to simplify common tasks:
|
104
103
|
|
105
104
|
# Ask for password
|
106
105
|
password
|
@@ -135,21 +134,6 @@ simplify common tasks using the following methods:
|
|
135
134
|
# Ask editor, supplying initial text
|
136
135
|
ask_editor 'previous data to update'
|
137
136
|
|
138
|
-
# Display a generic Growl notification
|
139
|
-
notify 'Something happened'
|
140
|
-
|
141
|
-
# Display an 'info' status notification
|
142
|
-
notify_info 'You have #{emails.length} new email(s)'
|
143
|
-
|
144
|
-
# Display an 'ok' status notification
|
145
|
-
notify_ok 'Gems updated'
|
146
|
-
|
147
|
-
# Display a 'warning' status notification
|
148
|
-
notify_warning '1 gem failed installation'
|
149
|
-
|
150
|
-
# Display an 'error' status notification
|
151
|
-
notify_error "Gem #{name} failed"
|
152
|
-
|
153
137
|
# Choose from an array of elements
|
154
138
|
choice = choose("Favorite language?", :ruby, :perl, :js)
|
155
139
|
|
@@ -181,6 +165,32 @@ simplify common tasks using the following methods:
|
|
181
165
|
end
|
182
166
|
end
|
183
167
|
|
168
|
+
== Growl Notifications
|
169
|
+
|
170
|
+
Commander provides methods for displaying Growl notifications. To use these
|
171
|
+
methods you need to install http://github.com/visionmedia/growl which utilizes
|
172
|
+
the growlnotify[http://growl.info/extras.php#growlnotify] executable. Note that
|
173
|
+
growl is auto-imported by Commander when available, no need to require.
|
174
|
+
|
175
|
+
# Display a generic Growl notification
|
176
|
+
notify 'Something happened'
|
177
|
+
|
178
|
+
# Display an 'info' status notification
|
179
|
+
notify_info 'You have #{emails.length} new email(s)'
|
180
|
+
|
181
|
+
# Display an 'ok' status notification
|
182
|
+
notify_ok 'Gems updated'
|
183
|
+
|
184
|
+
# Display a 'warning' status notification
|
185
|
+
notify_warning '1 gem failed installation'
|
186
|
+
|
187
|
+
# Display an 'error' status notification
|
188
|
+
notify_error "Gem #{name} failed"
|
189
|
+
|
190
|
+
growlnotify can also be installed via homebrew[http://mxcl.github.com/homebrew/]:
|
191
|
+
|
192
|
+
$ brew install growlnotify
|
193
|
+
|
184
194
|
== Commander Goodies
|
185
195
|
|
186
196
|
=== Option Defaults
|
@@ -315,15 +325,9 @@ http://github.com/visionmedia/terminal-table
|
|
315
325
|
| | | | | get it while its hot! |
|
316
326
|
+----------+-------+----+--------+-----------------------+
|
317
327
|
|
318
|
-
== Growl Notifications
|
319
|
-
|
320
|
-
To utilize the #notify and #notify_STATUS methods you need to install
|
321
|
-
http://github.com/visionmedia/growl which utilizes the 'growlnotify' executable.
|
322
|
-
Note that growl is auto-imported by Commander when available, no need to require.
|
323
|
-
|
324
328
|
== Running Specifications
|
325
329
|
|
326
|
-
$
|
330
|
+
$ rake spec
|
327
331
|
|
328
332
|
OR
|
329
333
|
|
data/Rakefile
CHANGED
@@ -1,16 +1,33 @@
|
|
1
|
-
|
2
1
|
$:.unshift 'lib'
|
3
|
-
|
2
|
+
|
4
3
|
require 'rubygems'
|
4
|
+
|
5
|
+
load_errors = ['highline', 'echoe'].map do |g|
|
6
|
+
begin
|
7
|
+
require g
|
8
|
+
nil
|
9
|
+
rescue LoadError
|
10
|
+
"The #{g} gem is not installed. Please run:\n\tgem install #{g}"
|
11
|
+
end
|
12
|
+
end.compact
|
13
|
+
abort "Missing dependencies!\n" + load_errors.join("\n") unless load_errors.empty?
|
14
|
+
|
15
|
+
require 'commander'
|
5
16
|
require 'rake'
|
6
|
-
require 'echoe'
|
7
17
|
|
8
18
|
Echoe.new "commander", Commander::VERSION do |p|
|
9
|
-
p.
|
10
|
-
p.email = "tj@vision-media.ca"
|
19
|
+
p.email = "ggilder@tractionco.com"
|
11
20
|
p.summary = "The complete solution for Ruby command-line executables"
|
12
21
|
p.url = "http://visionmedia.github.com/commander"
|
13
22
|
p.runtime_dependencies << "highline >=1.5.0"
|
23
|
+
p.development_dependencies << "echoe >=4.0.0"
|
24
|
+
p.development_dependencies << "sdoc >=0.2.20"
|
25
|
+
p.development_dependencies << "rspec ~>1.3"
|
26
|
+
|
27
|
+
p.eval = Proc.new do
|
28
|
+
self.authors = ["TJ Holowaychuk", "Gabriel Gilder"]
|
29
|
+
self.default_executable = "commander"
|
30
|
+
end
|
14
31
|
end
|
15
32
|
|
16
33
|
Dir['tasks/**/*.rake'].sort.each { |lib| load lib }
|
data/commander.gemspec
CHANGED
@@ -1,35 +1,42 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
require File.join(File.dirname(__FILE__), 'lib', 'commander', 'version')
|
5
4
|
s.name = %q{commander}
|
6
|
-
s.version =
|
5
|
+
s.version = "4.0.5"
|
7
6
|
|
8
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
9
|
-
s.authors = [
|
10
|
-
s.
|
8
|
+
s.authors = [%q{TJ Holowaychuk}, %q{Gabriel Gilder}]
|
9
|
+
s.date = %q{2011-08-09}
|
11
10
|
s.description = %q{The complete solution for Ruby command-line executables}
|
12
|
-
s.email = %q{
|
13
|
-
s.executables = [
|
14
|
-
s.extra_rdoc_files = [
|
15
|
-
s.files = [
|
11
|
+
s.email = %q{ggilder@tractionco.com}
|
12
|
+
s.executables = [%q{commander}]
|
13
|
+
s.extra_rdoc_files = [%q{README.rdoc}, %q{bin/commander}, %q{lib/commander.rb}, %q{lib/commander/blank.rb}, %q{lib/commander/command.rb}, %q{lib/commander/core_ext.rb}, %q{lib/commander/core_ext/array.rb}, %q{lib/commander/core_ext/object.rb}, %q{lib/commander/delegates.rb}, %q{lib/commander/help_formatters.rb}, %q{lib/commander/help_formatters/base.rb}, %q{lib/commander/help_formatters/terminal.rb}, %q{lib/commander/help_formatters/terminal/command_help.erb}, %q{lib/commander/help_formatters/terminal/help.erb}, %q{lib/commander/help_formatters/terminal_compact.rb}, %q{lib/commander/help_formatters/terminal_compact/command_help.erb}, %q{lib/commander/help_formatters/terminal_compact/help.erb}, %q{lib/commander/import.rb}, %q{lib/commander/platform.rb}, %q{lib/commander/runner.rb}, %q{lib/commander/user_interaction.rb}, %q{lib/commander/version.rb}, %q{tasks/dev_setup.rake}, %q{tasks/docs.rake}, %q{tasks/gemspec.rake}]
|
14
|
+
s.files = [%q{DEVELOPMENT}, %q{History.rdoc}, %q{Manifest}, %q{README.rdoc}, %q{Rakefile}, %q{bin/commander}, %q{commander.gemspec}, %q{lib/commander.rb}, %q{lib/commander/blank.rb}, %q{lib/commander/command.rb}, %q{lib/commander/core_ext.rb}, %q{lib/commander/core_ext/array.rb}, %q{lib/commander/core_ext/object.rb}, %q{lib/commander/delegates.rb}, %q{lib/commander/help_formatters.rb}, %q{lib/commander/help_formatters/base.rb}, %q{lib/commander/help_formatters/terminal.rb}, %q{lib/commander/help_formatters/terminal/command_help.erb}, %q{lib/commander/help_formatters/terminal/help.erb}, %q{lib/commander/help_formatters/terminal_compact.rb}, %q{lib/commander/help_formatters/terminal_compact/command_help.erb}, %q{lib/commander/help_formatters/terminal_compact/help.erb}, %q{lib/commander/import.rb}, %q{lib/commander/platform.rb}, %q{lib/commander/runner.rb}, %q{lib/commander/user_interaction.rb}, %q{lib/commander/version.rb}, %q{spec/command_spec.rb}, %q{spec/core_ext/array_spec.rb}, %q{spec/core_ext/object_spec.rb}, %q{spec/help_formatters/terminal_spec.rb}, %q{spec/runner_spec.rb}, %q{spec/spec.opts}, %q{spec/spec_helper.rb}, %q{spec/ui_spec.rb}, %q{tasks/dev_setup.rake}, %q{tasks/docs.rake}, %q{tasks/gemspec.rake}]
|
16
15
|
s.homepage = %q{http://visionmedia.github.com/commander}
|
17
|
-
s.rdoc_options = [
|
18
|
-
s.require_paths = [
|
16
|
+
s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Commander}, %q{--main}, %q{README.rdoc}]
|
17
|
+
s.require_paths = [%q{lib}]
|
19
18
|
s.rubyforge_project = %q{commander}
|
20
|
-
s.rubygems_version = %q{1.
|
19
|
+
s.rubygems_version = %q{1.8.6}
|
21
20
|
s.summary = %q{The complete solution for Ruby command-line executables}
|
22
21
|
|
23
22
|
if s.respond_to? :specification_version then
|
24
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
23
|
s.specification_version = 3
|
26
24
|
|
27
|
-
if Gem::Version.new(Gem::
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
26
|
s.add_runtime_dependency(%q<highline>, [">= 1.5.0"])
|
27
|
+
s.add_development_dependency(%q<echoe>, [">= 4.0.0"])
|
28
|
+
s.add_development_dependency(%q<sdoc>, [">= 0.2.20"])
|
29
|
+
s.add_development_dependency(%q<rspec>, ["~> 1.3"])
|
29
30
|
else
|
30
31
|
s.add_dependency(%q<highline>, [">= 1.5.0"])
|
32
|
+
s.add_dependency(%q<echoe>, [">= 4.0.0"])
|
33
|
+
s.add_dependency(%q<sdoc>, [">= 0.2.20"])
|
34
|
+
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
31
35
|
end
|
32
36
|
else
|
33
37
|
s.add_dependency(%q<highline>, [">= 1.5.0"])
|
38
|
+
s.add_dependency(%q<echoe>, [">= 4.0.0"])
|
39
|
+
s.add_dependency(%q<sdoc>, [">= 0.2.20"])
|
40
|
+
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
34
41
|
end
|
35
42
|
end
|
data/lib/commander/platform.rb
CHANGED
data/lib/commander/runner.rb
CHANGED
@@ -66,7 +66,7 @@ module Commander
|
|
66
66
|
OptionParser::InvalidOption,
|
67
67
|
OptionParser::InvalidArgument,
|
68
68
|
OptionParser::MissingArgument => e
|
69
|
-
abort e
|
69
|
+
abort e.to_s
|
70
70
|
rescue => e
|
71
71
|
abort "error: #{e}. Use --trace to view backtrace"
|
72
72
|
end
|
@@ -319,12 +319,19 @@ module Commander
|
|
319
319
|
# Parse global command options.
|
320
320
|
|
321
321
|
def parse_global_options
|
322
|
-
|
322
|
+
|
323
|
+
parser = options.inject(OptionParser.new) do |options, option|
|
323
324
|
options.on *option[:args], &global_option_proc(option[:switches], &option[:proc])
|
324
|
-
end
|
325
|
-
|
326
|
-
|
327
|
-
|
325
|
+
end
|
326
|
+
|
327
|
+
options = @args.dup
|
328
|
+
begin
|
329
|
+
parser.parse!(options)
|
330
|
+
rescue OptionParser::InvalidOption => e
|
331
|
+
# Remove the offending args and retry.
|
332
|
+
options = options.reject { |o| e.args.include?(o) }
|
333
|
+
retry
|
334
|
+
end
|
328
335
|
end
|
329
336
|
|
330
337
|
##
|
@@ -55,7 +55,67 @@ module Commander
|
|
55
55
|
def log action, *args
|
56
56
|
say '%15s %s' % [action, args.join(' ')]
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
|
+
##
|
60
|
+
# 'Say' something using the OK color (green).
|
61
|
+
#
|
62
|
+
# === Examples
|
63
|
+
# say_ok 'Everything is fine'
|
64
|
+
# say_ok 'It is ok', 'This is ok too'
|
65
|
+
#
|
66
|
+
|
67
|
+
def say_ok *args
|
68
|
+
args.each do |arg|
|
69
|
+
say $terminal.color(arg, :green)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# 'Say' something using the WARNING color (yellow).
|
75
|
+
#
|
76
|
+
# === Examples
|
77
|
+
# say_warning 'This is a warning'
|
78
|
+
# say_warning 'Be careful', 'Think about it'
|
79
|
+
#
|
80
|
+
|
81
|
+
def say_warning *args
|
82
|
+
args.each do |arg|
|
83
|
+
say $terminal.color(arg, :yellow)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
##
|
88
|
+
# 'Say' something using the ERROR color (red).
|
89
|
+
#
|
90
|
+
# === Examples
|
91
|
+
# say_error 'Everything is not fine'
|
92
|
+
# say_error 'It is not ok', 'This is not ok too'
|
93
|
+
#
|
94
|
+
|
95
|
+
def say_error *args
|
96
|
+
args.each do |arg|
|
97
|
+
say $terminal.color(arg, :red)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# 'Say' something using the specified color
|
103
|
+
#
|
104
|
+
# === Examples
|
105
|
+
# color 'I am blue', :blue
|
106
|
+
# color 'I am bold', :bold
|
107
|
+
# color 'White on Red', :white, :on_red
|
108
|
+
#
|
109
|
+
# === Notes
|
110
|
+
# You may use:
|
111
|
+
# * color: black blue cyan green magenta red white yellow
|
112
|
+
# * style: blink bold clear underline
|
113
|
+
# * highligh: on_<color>
|
114
|
+
|
115
|
+
def color(*args)
|
116
|
+
say $terminal.color(*args)
|
117
|
+
end
|
118
|
+
|
59
119
|
##
|
60
120
|
# Speak _message_ using _voice_ which defaults
|
61
121
|
# to 'Alex', which is one of the better voices.
|
data/lib/commander/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
data/spec/core_ext/array_spec.rb
CHANGED
data/spec/runner_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Commander do
|
5
4
|
before :each do
|
@@ -110,6 +109,138 @@ describe Commander do
|
|
110
109
|
quiet.should be_true
|
111
110
|
end
|
112
111
|
end
|
112
|
+
|
113
|
+
describe "#parse_global_options" do
|
114
|
+
it 'should parse global options before command' do
|
115
|
+
global_option = nil
|
116
|
+
new_command_runner('--testing-global', 'foo') do
|
117
|
+
global_option('--testing-global') { global_option = 'MAGIC' }
|
118
|
+
|
119
|
+
command :foo do |c|
|
120
|
+
c.when_called {}
|
121
|
+
end
|
122
|
+
end.run!
|
123
|
+
global_option.should == 'MAGIC'
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should parse global options after command' do
|
127
|
+
global_option = nil
|
128
|
+
new_command_runner('foo','--testing-global') do
|
129
|
+
global_option('--testing-global') { global_option = 'MAGIC' }
|
130
|
+
|
131
|
+
command :foo do |c|
|
132
|
+
c.when_called {}
|
133
|
+
end
|
134
|
+
end.run!
|
135
|
+
global_option.should == 'MAGIC'
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should parse global options placed before command options' do
|
139
|
+
global_option = nil
|
140
|
+
new_command_runner('foo', '--testing-global', '--testing-command') do
|
141
|
+
global_option('--testing-global') { global_option = 'MAGIC' }
|
142
|
+
|
143
|
+
command :foo do |c|
|
144
|
+
c.option('--testing-command') {}
|
145
|
+
c.when_called {}
|
146
|
+
end
|
147
|
+
end.run!
|
148
|
+
|
149
|
+
global_option.should == 'MAGIC'
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'should parse global options placed after command options' do
|
153
|
+
global_option = nil
|
154
|
+
new_command_runner('foo', '--testing-command', '--testing-global') do
|
155
|
+
global_option('--testing-global') { global_option = 'MAGIC' }
|
156
|
+
|
157
|
+
command :foo do |c|
|
158
|
+
c.option('--testing-command') {}
|
159
|
+
c.when_called {}
|
160
|
+
end
|
161
|
+
end.run!
|
162
|
+
|
163
|
+
global_option.should == 'MAGIC'
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'should parse global options surrounded by command options' do
|
167
|
+
global_option = nil
|
168
|
+
new_command_runner('foo', '--testing-command', '--testing-global', '--other-command') do
|
169
|
+
global_option('--testing-global') { global_option = 'MAGIC' }
|
170
|
+
|
171
|
+
command :foo do |c|
|
172
|
+
c.option('--testing-command') {}
|
173
|
+
c.option('--other-command') {}
|
174
|
+
c.when_called {}
|
175
|
+
end
|
176
|
+
end.run!
|
177
|
+
|
178
|
+
global_option.should == 'MAGIC'
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should not parse command options' do
|
182
|
+
global_option = nil
|
183
|
+
command_option = nil
|
184
|
+
new_command_runner('foo', '--testing-command', '--testing-global') do
|
185
|
+
global_option('--testing-global') { global_option = 'MAGIC' }
|
186
|
+
|
187
|
+
command :foo do |c|
|
188
|
+
c.option('--testing-command') { command_option = 'NO!' }
|
189
|
+
c.when_called {}
|
190
|
+
end
|
191
|
+
end.parse_global_options
|
192
|
+
|
193
|
+
command_option.should be_nil
|
194
|
+
global_option.should == 'MAGIC'
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should not affect command arguments with values' do
|
198
|
+
global_option = nil
|
199
|
+
command_option = nil
|
200
|
+
new_command_runner('foo', '--testing-command', 'bar', '--testing-global') do
|
201
|
+
global_option('--testing-global') { global_option = 'MAGIC' }
|
202
|
+
|
203
|
+
command :foo do |c|
|
204
|
+
c.option('--testing-command VALUE') { |v| command_option = v }
|
205
|
+
c.when_called {}
|
206
|
+
end
|
207
|
+
end.run!
|
208
|
+
|
209
|
+
command_option.should == 'bar'
|
210
|
+
global_option.should == 'MAGIC'
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should not affect global arguments with values' do
|
214
|
+
global_option = nil
|
215
|
+
new_command_runner('foo', '--testing-command', '--testing-global', 'bar') do
|
216
|
+
global_option('--testing-global VALUE') { |v| global_option = v }
|
217
|
+
|
218
|
+
command :foo do |c|
|
219
|
+
c.option('--testing-command') { }
|
220
|
+
c.when_called {}
|
221
|
+
end
|
222
|
+
end.run!
|
223
|
+
|
224
|
+
global_option.should == 'bar'
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'should allow global arguments with values before command arguments (github issue #8)' do
|
228
|
+
global_option = nil
|
229
|
+
command_option = nil
|
230
|
+
new_command_runner('foo', '--config', 'path', 'bar') do
|
231
|
+
global_option('--config VALUE') { |v| global_option = v }
|
232
|
+
|
233
|
+
command :foo do |c|
|
234
|
+
c.option('bar') { command_option = 'bar' }
|
235
|
+
c.when_called {}
|
236
|
+
end
|
237
|
+
end.run!
|
238
|
+
|
239
|
+
global_option.should == 'path'
|
240
|
+
command_option.should == 'bar'
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
113
244
|
|
114
245
|
describe "#remove_global_options" do
|
115
246
|
it "should remove only specified switches" do
|
data/spec/ui_spec.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
desc 'Install development dependencies'
|
2
|
+
task :dev_setup do
|
3
|
+
ObjectSpace.each_object(Echoe) do |o|
|
4
|
+
o.development_dependencies.each do |gem_string|
|
5
|
+
gem_name, version = gem_string.split(' ', 2)
|
6
|
+
cmd = "gem install #{gem_name}"
|
7
|
+
cmd += " --version '#{version}'" if (version)
|
8
|
+
puts `#{cmd}`
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/tasks/docs.rake
CHANGED
metadata
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 53
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 4.0.5
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- TJ Holowaychuk
|
14
|
+
- Gabriel Gilder
|
9
15
|
autorequire:
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
18
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable: commander
|
19
|
+
date: 2011-08-09 00:00:00 Z
|
15
20
|
dependencies:
|
16
21
|
- !ruby/object:Gem::Dependency
|
17
22
|
name: highline
|
@@ -21,11 +26,63 @@ dependencies:
|
|
21
26
|
requirements:
|
22
27
|
- - ">="
|
23
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 5
|
33
|
+
- 0
|
24
34
|
version: 1.5.0
|
25
35
|
type: :runtime
|
26
36
|
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: echoe
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 63
|
46
|
+
segments:
|
47
|
+
- 4
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
version: 4.0.0
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: sdoc
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 63
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 2
|
65
|
+
- 20
|
66
|
+
version: 0.2.20
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 9
|
78
|
+
segments:
|
79
|
+
- 1
|
80
|
+
- 3
|
81
|
+
version: "1.3"
|
82
|
+
type: :development
|
83
|
+
version_requirements: *id004
|
27
84
|
description: The complete solution for Ruby command-line executables
|
28
|
-
email:
|
85
|
+
email: ggilder@tractionco.com
|
29
86
|
executables:
|
30
87
|
- commander
|
31
88
|
extensions: []
|
@@ -53,9 +110,11 @@ extra_rdoc_files:
|
|
53
110
|
- lib/commander/runner.rb
|
54
111
|
- lib/commander/user_interaction.rb
|
55
112
|
- lib/commander/version.rb
|
113
|
+
- tasks/dev_setup.rake
|
56
114
|
- tasks/docs.rake
|
57
115
|
- tasks/gemspec.rake
|
58
116
|
files:
|
117
|
+
- DEVELOPMENT
|
59
118
|
- History.rdoc
|
60
119
|
- Manifest
|
61
120
|
- README.rdoc
|
@@ -90,9 +149,9 @@ files:
|
|
90
149
|
- spec/spec.opts
|
91
150
|
- spec/spec_helper.rb
|
92
151
|
- spec/ui_spec.rb
|
152
|
+
- tasks/dev_setup.rake
|
93
153
|
- tasks/docs.rake
|
94
154
|
- tasks/gemspec.rake
|
95
|
-
has_rdoc: true
|
96
155
|
homepage: http://visionmedia.github.com/commander
|
97
156
|
licenses: []
|
98
157
|
|
@@ -111,17 +170,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
170
|
requirements:
|
112
171
|
- - ">="
|
113
172
|
- !ruby/object:Gem::Version
|
173
|
+
hash: 3
|
174
|
+
segments:
|
175
|
+
- 0
|
114
176
|
version: "0"
|
115
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
178
|
none: false
|
117
179
|
requirements:
|
118
180
|
- - ">="
|
119
181
|
- !ruby/object:Gem::Version
|
182
|
+
hash: 11
|
183
|
+
segments:
|
184
|
+
- 1
|
185
|
+
- 2
|
120
186
|
version: "1.2"
|
121
187
|
requirements: []
|
122
188
|
|
123
189
|
rubyforge_project: commander
|
124
|
-
rubygems_version: 1.
|
190
|
+
rubygems_version: 1.8.6
|
125
191
|
signing_key:
|
126
192
|
specification_version: 3
|
127
193
|
summary: The complete solution for Ruby command-line executables
|