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