visionmedia-commander 3.0.2 → 3.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 +4 -0
- data/commander.gemspec +1 -1
- data/lib/commander/core_ext/object.rb +1 -1
- data/lib/commander/runner.rb +9 -5
- data/lib/commander/version.rb +1 -1
- data/spec/runner_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -1
- metadata +1 -1
data/History.rdoc
CHANGED
data/commander.gemspec
CHANGED
@@ -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
|
##
|
data/lib/commander/runner.rb
CHANGED
@@ -102,11 +102,15 @@ module Commander
|
|
102
102
|
#
|
103
103
|
|
104
104
|
def command name, &block
|
105
|
-
if block
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
##
|
data/lib/commander/version.rb
CHANGED
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