From 575c0892766531d724e18f31fe60386feac1f3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mon=20ou=C3=AFe?= Date: Mon, 25 Apr 2011 08:04:55 +0200 Subject: [PATCH] Allowed to change description of a command in CommandSet --- lib/pry/command_set.rb | 12 ++++++++++++ test/test.rb | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index 4c92d6a3..99349eb1 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -102,5 +102,17 @@ class Pry raise NoCommandError.new(name, self) end end + + # Sets the description for a command (replacing the old + # description.) + # @param [String] name The command name. + # @param [String] description The command description. + # @example + # MyCommands = Pry::CommandSet.new :test do + # desc "help", "help description" + # end + def desc(name, description) + commands[name].description = description + end end end diff --git a/test/test.rb b/test/test.rb index 64766899..0f036b0a 100644 --- a/test/test.rb +++ b/test/test.rb @@ -904,4 +904,11 @@ describe Pry::CommandSet do @set.run_command nil, 'bar' run.should == true end + + it 'should be able to change the descritpions of methods' do + @set.command('foo', 'bar') {} + @set.desc 'foo', 'baz' + + @set.commands['foo'].description.should == 'baz' + end end