visionmedia-commander 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,4 +1,8 @@
1
1
 
2
+ === 3.0.3 / 2009-03-12
3
+
4
+ * Added #alias_command
5
+
2
6
  === 3.0.2 / 2009-03-12
3
7
 
4
8
  * Added terminal formatter specs
data/commander.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{commander}
5
- s.version = "3.0.2"
5
+ s.version = "3.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"]
@@ -16,7 +16,7 @@ class Object
16
16
  extend Forwardable
17
17
  include Commander::UI
18
18
 
19
- def_delegators :$command_runner, :add_command, :command, :program, :run!, :commands
19
+ def_delegators :$command_runner, :add_command, :command, :program, :run!, :commands, :alias_command
20
20
  def_delegators Commander::UI::ProgressBar, :progress
21
21
 
22
22
  ##
@@ -102,11 +102,15 @@ module Commander
102
102
  #
103
103
 
104
104
  def command name, &block
105
- if block
106
- yield add_command(Commander::Command.new(name))
107
- else
108
- @commands[name.to_s] or raise InvalidCommandError, "invalid command '#{ name || 'nil' }'", caller
109
- end
105
+ yield add_command(Commander::Command.new(name)) if block
106
+ @commands[name.to_s] or raise InvalidCommandError, "invalid command '#{ name || 'nil' }'", caller
107
+ end
108
+
109
+ ##
110
+ # Alias command +name+ with +alias_name+.
111
+
112
+ def alias_command alias_name, name
113
+ @commands[alias_name.to_s] = command name
110
114
  end
111
115
 
112
116
  ##
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Commander
3
- VERSION = '3.0.2'
3
+ VERSION = '3.0.3'
4
4
  end
data/spec/runner_spec.rb CHANGED
@@ -34,6 +34,13 @@ describe Commander do
34
34
  end
35
35
  end
36
36
 
37
+ describe "#alias_command" do
38
+ it "should allow aliasing of any command" do
39
+ alias_command :foo, :test
40
+ command(:foo).should == command(:test)
41
+ end
42
+ end
43
+
37
44
  describe "--version" do
38
45
  it "should output program version" do
39
46
  new_command_runner '--version' do
data/spec/spec_helper.rb CHANGED
@@ -35,6 +35,6 @@ def new_command_runner *args, &block
35
35
  program :version, '1.2.3'
36
36
  program :description, 'something'
37
37
  create_test_command
38
- yield if block_given?
38
+ yield if block
39
39
  command_runner
40
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionmedia-commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk