commander 3.3.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,4 +1,16 @@
1
1
 
2
+ === 4.0.0 / 2009-10-10
3
+
4
+ * Changed; Aliased #when_called as #action [#9]
5
+ * Changed; Sort commands and aliases alphabetically.
6
+ * Changed; Sort aliases alphabetically
7
+ * Changed; Sort commands alphabetically.
8
+ * Changed; require user to require 'commander/import' for dsl
9
+ * Fixed broken regexp; Changed :int_message, only traps INT when available
10
+ * Fixed Ruby 1.9 warning caused by removing object_id from Object
11
+ * Removed #eval const hack
12
+ * Moving to Gemcutter (GRRRR Github)
13
+
2
14
  === 3.3.0 / 2009-05-12
3
15
 
4
16
  * Added #choose
data/Manifest CHANGED
@@ -29,8 +29,8 @@ spec/core_ext/object_spec.rb
29
29
  spec/help_formatters/base_spec.rb
30
30
  spec/help_formatters/terminal_spec.rb
31
31
  spec/runner_spec.rb
32
+ spec/spec.opts
32
33
  spec/spec_helper.rb
33
34
  spec/ui_spec.rb
34
35
  tasks/docs.rake
35
36
  tasks/gemspec.rake
36
- tasks/spec.rake
data/README.rdoc CHANGED
@@ -27,13 +27,13 @@ features, and an elegant API.
27
27
 
28
28
  == Installation
29
29
 
30
- Due to issues with Github and supporting previous releases, until 4.0 you must:
31
- sudo gem install visionmedia-commander --version 3.2.9
30
+ Install [Gemcutter](http://gemcutter.org) and execute:
31
+ $ sudo gem install commander
32
32
 
33
33
  == Example
34
34
 
35
35
  For more option examples view the Commander::Command#option method. Also
36
- an important feature to note is that when_called may be a class to instantiate,
36
+ an important feature to note is that action may be a class to instantiate,
37
37
  as well as an object, specifying a method to call, so view the RDoc for more information.
38
38
 
39
39
  require 'rubygems'
@@ -47,7 +47,7 @@ as well as an object, specifying a method to call, so view the RDoc for more inf
47
47
  command :foo do |c|
48
48
  c.syntax = 'foobar foo'
49
49
  c.description = 'Displays foo'
50
- c.when_called do |args, options|
50
+ c.action do |args, options|
51
51
  say 'foo'
52
52
  end
53
53
  end
@@ -57,7 +57,7 @@ as well as an object, specifying a method to call, so view the RDoc for more inf
57
57
  c.description = 'Display bar with optional prefix and suffix'
58
58
  c.option '--prefix STRING', String, 'Adds a prefix to bar'
59
59
  c.option '--suffix STRING', String, 'Adds a suffix to bar'
60
- c.when_called do |args, options|
60
+ c.action do |args, options|
61
61
  options.default :prefix => '(', :suffix => ')'
62
62
  say "#{options.prefix}bar#{options.suffix}"
63
63
  end
@@ -186,13 +186,13 @@ simplify common tasks using the following methods:
186
186
 
187
187
  === Option Defaults
188
188
 
189
- The options struct passed to #when_called provides a #default method, allowing you
189
+ The options struct passed to #action provides a #default method, allowing you
190
190
  to set defaults in a clean manor to options which have not been set.
191
191
 
192
192
  command :foo do |c|
193
193
  c.option '--interval SECONDS', Integer, 'Interval in seconds'
194
194
  c.option '--timeout SECONDS', Integer, 'Timeout in seconds'
195
- c.when_called do |args, options|
195
+ c.action do |args, options|
196
196
  options.default \
197
197
  :interval => 2,
198
198
  :timeout => 60
@@ -204,7 +204,7 @@ to set defaults in a clean manor to options which have not been set.
204
204
  Aliases can be created using the #alias_command method like below:
205
205
 
206
206
  command :'install gem' do |c|
207
- c.when_called { puts 'foo' }
207
+ c.action { puts 'foo' }
208
208
  end
209
209
  alias_command :'gem install', :'install gem'
210
210
 
@@ -214,7 +214,7 @@ as if it was invoked via the command line:
214
214
  command :'install gem' do |c|
215
215
  c.syntax = 'install gem <name> [options]'
216
216
  c.option '--dest DIR', String, 'Destination directory'
217
- c.when_called { |args, options| puts "installing #{args.first} to #{options.dest}" }
217
+ c.action { |args, options| puts "installing #{args.first} to #{options.dest}" }
218
218
  end
219
219
  alias_command :update, :'install gem', 'rubygems', '--dest', 'some_path'
220
220
 
@@ -270,7 +270,7 @@ means that instead of the following:
270
270
 
271
271
  global_option('--verbose') { $verbose = true }
272
272
  ...
273
- c.when_called do |args, options|
273
+ c.action do |args, options|
274
274
  say 'foo' if $verbose
275
275
  ...
276
276
 
@@ -278,20 +278,20 @@ You may:
278
278
 
279
279
  global_option '--verbose'
280
280
  ...
281
- c.when_called do |args, options|
281
+ c.action do |args, options|
282
282
  say 'foo' if options.verbose
283
283
  ...
284
284
 
285
285
  === Formatters
286
286
 
287
287
  Two core formatters are currently available, the default Terminal formatter as well
288
- as TerminalCompact. To utilize a different formatter simply use :help_formatter like below:
288
+ as TerminalCompact. To utilize a different formatter simply use :formatter like below:
289
289
 
290
- program :help_formatter, Commander::HelpFormatter::TerminalCompact
290
+ program :formatter, Commander::HelpFormatter::TerminalCompact
291
291
 
292
292
  Or utilize the help formatter aliases:
293
293
 
294
- program :help_formatter, :compact
294
+ program :formatter, :compact
295
295
 
296
296
  This abstraction could be utilized to generate HTML documentation for your executable.
297
297
 
@@ -322,10 +322,18 @@ To utilize the #notify and #notify_STATUS methods you need to install
322
322
  http://github.com/visionmedia/growl which utilizes the 'growlnotify' executable.
323
323
  Note that growl is auto-imported by Commander when available, no need to require.
324
324
 
325
+ == Running Specifications
326
+
327
+ $ autospec
328
+
329
+ OR
330
+
331
+ $ spec --color spec
332
+
325
333
  == Contrib
326
334
 
327
335
  Feel free to fork and request a pull, or submit a ticket
328
- http://visionmedia.lighthouseapp.com/projects/27643-commander
336
+ http://github.com/visionmedia/commander/issues
329
337
 
330
338
  == Known Issues
331
339
 
data/bin/commander CHANGED
@@ -13,7 +13,7 @@ command :init do |c|
13
13
  c.description = 'Initialize an empty <file> with a commander template,
14
14
  allowing very quick creation of commander executables.'
15
15
  c.example 'Create a new file with a commander template.', 'commander init bin/my_executable'
16
- c.when_called do |args, options|
16
+ c.action do |args, options|
17
17
  file = args.shift || abort('file argument required.')
18
18
  name = ask 'Machine name of program: '
19
19
  description = ask 'Describe your program: '
@@ -39,7 +39,7 @@ command :init do |c|
39
39
  c.description = ''
40
40
  c.example 'description', 'command example'
41
41
  c.option '--some-switch', 'Some switch that does something'
42
- c.when_called do |args, options|
42
+ c.action do |args, options|
43
43
  # Do something or c.when_called #{name.capitalize}::Commands::#{command.capitalize}
44
44
  end
45
45
  end
data/commander.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{commander}
5
- s.version = "3.3.0"
5
+ s.version = "4.0.0"
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{2009-10-08}
9
+ s.date = %q{2009-10-10}
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}
13
13
  s.executables = ["commander"]
14
- s.extra_rdoc_files = ["README.rdoc", "bin/commander", "lib/commander.rb", "lib/commander/blank.rb", "lib/commander/command.rb", "lib/commander/core_ext.rb", "lib/commander/core_ext/array.rb", "lib/commander/core_ext/object.rb", "lib/commander/delegates.rb", "lib/commander/help_formatters.rb", "lib/commander/help_formatters/base.rb", "lib/commander/help_formatters/terminal.rb", "lib/commander/help_formatters/terminal/command_help.erb", "lib/commander/help_formatters/terminal/help.erb", "lib/commander/help_formatters/terminal_compact.rb", "lib/commander/help_formatters/terminal_compact/command_help.erb", "lib/commander/help_formatters/terminal_compact/help.erb", "lib/commander/import.rb", "lib/commander/runner.rb", "lib/commander/user_interaction.rb", "lib/commander/version.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
15
- s.files = ["History.rdoc", "Manifest", "README.rdoc", "Rakefile", "bin/commander", "commander.gemspec", "lib/commander.rb", "lib/commander/blank.rb", "lib/commander/command.rb", "lib/commander/core_ext.rb", "lib/commander/core_ext/array.rb", "lib/commander/core_ext/object.rb", "lib/commander/delegates.rb", "lib/commander/help_formatters.rb", "lib/commander/help_formatters/base.rb", "lib/commander/help_formatters/terminal.rb", "lib/commander/help_formatters/terminal/command_help.erb", "lib/commander/help_formatters/terminal/help.erb", "lib/commander/help_formatters/terminal_compact.rb", "lib/commander/help_formatters/terminal_compact/command_help.erb", "lib/commander/help_formatters/terminal_compact/help.erb", "lib/commander/import.rb", "lib/commander/runner.rb", "lib/commander/user_interaction.rb", "lib/commander/version.rb", "spec/command_spec.rb", "spec/core_ext/array_spec.rb", "spec/core_ext/object_spec.rb", "spec/help_formatters/base_spec.rb", "spec/help_formatters/terminal_spec.rb", "spec/runner_spec.rb", "spec/spec_helper.rb", "spec/ui_spec.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
14
+ s.extra_rdoc_files = ["README.rdoc", "bin/commander", "lib/commander.rb", "lib/commander/blank.rb", "lib/commander/command.rb", "lib/commander/core_ext.rb", "lib/commander/core_ext/array.rb", "lib/commander/core_ext/object.rb", "lib/commander/delegates.rb", "lib/commander/help_formatters.rb", "lib/commander/help_formatters/base.rb", "lib/commander/help_formatters/terminal.rb", "lib/commander/help_formatters/terminal/command_help.erb", "lib/commander/help_formatters/terminal/help.erb", "lib/commander/help_formatters/terminal_compact.rb", "lib/commander/help_formatters/terminal_compact/command_help.erb", "lib/commander/help_formatters/terminal_compact/help.erb", "lib/commander/import.rb", "lib/commander/runner.rb", "lib/commander/user_interaction.rb", "lib/commander/version.rb", "tasks/docs.rake", "tasks/gemspec.rake"]
15
+ s.files = ["History.rdoc", "Manifest", "README.rdoc", "Rakefile", "bin/commander", "commander.gemspec", "lib/commander.rb", "lib/commander/blank.rb", "lib/commander/command.rb", "lib/commander/core_ext.rb", "lib/commander/core_ext/array.rb", "lib/commander/core_ext/object.rb", "lib/commander/delegates.rb", "lib/commander/help_formatters.rb", "lib/commander/help_formatters/base.rb", "lib/commander/help_formatters/terminal.rb", "lib/commander/help_formatters/terminal/command_help.erb", "lib/commander/help_formatters/terminal/help.erb", "lib/commander/help_formatters/terminal_compact.rb", "lib/commander/help_formatters/terminal_compact/command_help.erb", "lib/commander/help_formatters/terminal_compact/help.erb", "lib/commander/import.rb", "lib/commander/runner.rb", "lib/commander/user_interaction.rb", "lib/commander/version.rb", "spec/command_spec.rb", "spec/core_ext/array_spec.rb", "spec/core_ext/object_spec.rb", "spec/help_formatters/base_spec.rb", "spec/help_formatters/terminal_spec.rb", "spec/runner_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/ui_spec.rb", "tasks/docs.rake", "tasks/gemspec.rake"]
16
16
  s.homepage = %q{http://visionmedia.github.com/commander}
17
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Commander", "--main", "README.rdoc"]
18
18
  s.require_paths = ["lib"]
@@ -142,6 +142,7 @@ module Commander
142
142
  raise ArgumentError, 'must pass an object, class, or block.' if args.empty? and !block
143
143
  @when_called = block ? [block] : args
144
144
  end
145
+ alias :action :when_called
145
146
 
146
147
  ##
147
148
  # Run the command with _args_.
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Commander
3
- VERSION = '3.3.0'
3
+ VERSION = '4.0.0'
4
4
  end
data/spec/command_spec.rb CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
2
4
  describe Commander::Command do
3
5
 
4
6
  before :each do
@@ -54,6 +56,13 @@ describe Commander::Command do
54
56
  @command.when_called object
55
57
  @command.run 'foo'
56
58
  end
59
+
60
+ it "should allow #action as an alias to #when_called" do
61
+ object = mock 'Object'
62
+ object.should_receive(:call).once
63
+ @command.action object
64
+ @command.run 'foo'
65
+ end
57
66
 
58
67
  it "calling an arbitrary method when an object is called" do
59
68
  object = mock 'Object'
@@ -1,4 +1,6 @@
1
1
 
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
2
4
  describe Array do
3
5
 
4
6
  describe "#parse" do
@@ -1,4 +1,6 @@
1
1
 
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
2
4
  describe Object do
3
5
 
4
6
  describe "#get_binding" do
@@ -1,4 +1,6 @@
1
1
 
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
2
4
  describe Commander::HelpFormatter do
3
5
 
4
6
  before :each do
@@ -1,4 +1,6 @@
1
1
 
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
2
4
  describe Commander::HelpFormatter::Terminal do
3
5
 
4
6
  before :each do
data/spec/runner_spec.rb CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
2
4
  describe Commander do
3
5
 
4
6
  before :each do
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
+ $:.unshift File.dirname(__FILE__) + '/../lib'
2
3
  require 'rubygems'
3
4
  require 'commander/import'
4
5
  require 'stringio'
@@ -47,7 +48,7 @@ end
47
48
 
48
49
  def run *args
49
50
  new_command_runner *args do
50
- program :help_formatter, Commander::HelpFormatter::Base
51
+ program :formatter, Commander::HelpFormatter::Base
51
52
  end.run!
52
53
  @output.string
53
54
  end
data/spec/ui_spec.rb CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
2
4
  describe Commander::UI do
3
5
 
4
6
  describe ".replace_tokens" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-08 00:00:00 -07:00
12
+ date: 2009-10-10 00:00:00 -07:00
13
13
  default_executable: commander
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -52,7 +52,6 @@ extra_rdoc_files:
52
52
  - lib/commander/version.rb
53
53
  - tasks/docs.rake
54
54
  - tasks/gemspec.rake
55
- - tasks/spec.rake
56
55
  files:
57
56
  - History.rdoc
58
57
  - Manifest
@@ -85,11 +84,11 @@ files:
85
84
  - spec/help_formatters/base_spec.rb
86
85
  - spec/help_formatters/terminal_spec.rb
87
86
  - spec/runner_spec.rb
87
+ - spec/spec.opts
88
88
  - spec/spec_helper.rb
89
89
  - spec/ui_spec.rb
90
90
  - tasks/docs.rake
91
91
  - tasks/gemspec.rake
92
- - tasks/spec.rake
93
92
  has_rdoc: true
94
93
  homepage: http://visionmedia.github.com/commander
95
94
  licenses: []
data/tasks/spec.rake DELETED
@@ -1,25 +0,0 @@
1
-
2
- require 'spec/rake/spectask'
3
-
4
- desc "Run all specifications"
5
- Spec::Rake::SpecTask.new(:spec) do |t|
6
- t.libs << "lib"
7
- t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
8
- end
9
-
10
- namespace :spec do
11
-
12
- desc "Run all specifications verbosely"
13
- Spec::Rake::SpecTask.new(:verbose) do |t|
14
- t.libs << "lib"
15
- t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
16
- end
17
-
18
- desc "Run specific specification verbosely (specify SPEC)"
19
- Spec::Rake::SpecTask.new(:select) do |t|
20
- t.libs << "lib"
21
- t.spec_files = [ENV["SPEC"]]
22
- t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
23
- end
24
-
25
- end