mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Show the contents of the process method by default
When creating a command using a custom subclass there may not be a readily available block. In that case defaulting to the process method seems reasonable for now.
This commit is contained in:
parent
12a4eb5784
commit
a970d5b29e
2 changed files with 9 additions and 1 deletions
|
@ -14,7 +14,7 @@ class Pry
|
|||
# Properties of the command itself (as passed as arguments to
|
||||
# {CommandSet#command} or {CommandSet#create_command}).
|
||||
class << self
|
||||
attr_accessor :block
|
||||
attr_writer :block
|
||||
attr_writer :description
|
||||
attr_writer :command_options
|
||||
attr_writer :match
|
||||
|
@ -45,6 +45,10 @@ class Pry
|
|||
@banner = arg if arg
|
||||
@banner || description
|
||||
end
|
||||
|
||||
def block
|
||||
@block || instance_method(:process) && instance_method(:process)
|
||||
end
|
||||
end
|
||||
|
||||
# Make those properties accessible to instances
|
||||
|
|
|
@ -618,5 +618,9 @@ describe "Pry::Command" do
|
|||
it "should allow creating custom sub-classes of Pry::Command" do
|
||||
mock_pry("my---test").should =~ /my-testmy-test/
|
||||
end
|
||||
|
||||
it "should show the source of the process method" do
|
||||
mock_pry("show-command my-test").should =~ /output.puts command_name/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue