mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
renamed requires_prefix option to use_prefix, and updated tests
This commit is contained in:
parent
309c3cf3cd
commit
57b9c7a505
5 changed files with 12 additions and 9 deletions
|
@ -56,7 +56,7 @@ class Pry
|
|||
_, cmd_data = commands.commands.find do |name, data|
|
||||
|
||||
prefix = Regexp.escape(Pry.config.command_prefix)
|
||||
prefix = "(?:#{prefix})?" unless data.options[:require_prefix]
|
||||
prefix = "(?:#{prefix})?" unless data.options[:use_prefix]
|
||||
|
||||
command_regex = /^#{prefix}#{convert_to_regex(name)}(?!\S)/
|
||||
|
||||
|
|
|
@ -68,6 +68,9 @@ class Pry
|
|||
# @option options [String] :listing The listing name of the
|
||||
# command. That is the name by which the command is looked up by
|
||||
# help and by show-command. Necessary for regex based commands.
|
||||
# @option options [Boolean] :use_prefix Whether the command uses
|
||||
# `Pry.config.command_prefix` prefix (if one is defined). Defaults
|
||||
# to true.
|
||||
# @yield The action to perform. The parameters in the block
|
||||
# determines the parameters the command will receive. All
|
||||
# parameters passed into the block will be strings. Successive
|
||||
|
@ -106,7 +109,7 @@ class Pry
|
|||
:argument_required => false,
|
||||
:interpolate => true,
|
||||
:listing => name,
|
||||
:require_prefix => true
|
||||
:use_prefix => true
|
||||
}.merge!(options)
|
||||
|
||||
unless command_dependencies_met? options
|
||||
|
@ -124,7 +127,7 @@ class Pry
|
|||
end
|
||||
|
||||
def each &block
|
||||
@commands.each(&block)
|
||||
@commands.each(&block)
|
||||
end
|
||||
|
||||
# Removes some commands from the set
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
|
||||
Input = Pry::CommandSet.new do
|
||||
|
||||
command "!", "Clear the input buffer. Useful if the parsing process goes wrong and you get stuck in the read loop." do
|
||||
command "!", "Clear the input buffer. Useful if the parsing process goes wrong and you get stuck in the read loop.", :use_prefix => false do
|
||||
output.puts "Input buffer cleared!"
|
||||
eval_string.replace("")
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ class Pry
|
|||
|
||||
Shell = Pry::CommandSet.new do
|
||||
|
||||
command(/\.(.*)/, "All text following a '.' is forwarded to the shell.", :listing => ".<shell command>", :require_prefix => false) do |cmd|
|
||||
command(/\.(.*)/, "All text following a '.' is forwarded to the shell.", :listing => ".<shell command>", :use_prefix => false) do |cmd|
|
||||
if cmd =~ /^cd\s+(.+)/i
|
||||
dest = $1
|
||||
begin
|
||||
|
|
|
@ -118,10 +118,10 @@ describe "Pry::CommandProcessor" do
|
|||
Pry.config.command_prefix = ''
|
||||
end
|
||||
|
||||
it 'should match a command preceded by the command_prefix when :require_prefix => false' do
|
||||
it 'should match a command preceded by the command_prefix when :use_prefix => false' do
|
||||
Pry.config.command_prefix = "%"
|
||||
|
||||
@pry.commands.command("test-command", "", :require_prefix => false) {}
|
||||
@pry.commands.command("test-command", "", :use_prefix => false) {}
|
||||
command, captures, pos = @command_processor.command_matched "%test-command hello", binding
|
||||
|
||||
command.name.should == "test-command"
|
||||
|
@ -131,10 +131,10 @@ describe "Pry::CommandProcessor" do
|
|||
Pry.config.command_prefix = ''
|
||||
end
|
||||
|
||||
it 'should match a command not preceded by the command_prefix when :require_prefix => false' do
|
||||
it 'should match a command not preceded by the command_prefix when :use_prefix => false' do
|
||||
Pry.config.command_prefix = "%"
|
||||
|
||||
@pry.commands.command("test-command", "", :require_prefix => false) {}
|
||||
@pry.commands.command("test-command", "", :use_prefix => false) {}
|
||||
command, captures, pos = @command_processor.command_matched "test-command hello", binding
|
||||
|
||||
command.name.should == "test-command"
|
||||
|
|
Loading…
Add table
Reference in a new issue