mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Fix wrong command groups
Fix issue #631 (In `help` output: aliases are no longer grouped under Aliases heading but under (other)) Forbid redefining a group of a command once it is initialized. Also, add some unit tests, checking for that, so we won't miss this if it happens next time. Reported-by: John Mair <jrmair@gmail.com> Cc: Rob Gleeson <rob@flowof.info> Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
This commit is contained in:
parent
6a54e34dad
commit
e0fdf24461
2 changed files with 29 additions and 13 deletions
|
@ -143,21 +143,21 @@ class Pry
|
||||||
# This is usually auto-generated from directory naming, but it can be
|
# This is usually auto-generated from directory naming, but it can be
|
||||||
# manually overridden if necessary.
|
# manually overridden if necessary.
|
||||||
def group(name=nil)
|
def group(name=nil)
|
||||||
@group = if name
|
@group ||= if name
|
||||||
name
|
name
|
||||||
else
|
|
||||||
case Pry::Method(block).source_file
|
|
||||||
when %r{/pry/.*_commands/(.*).rb}
|
|
||||||
$1.capitalize.gsub(/_/, " ")
|
|
||||||
when %r{(pry-\w+)-([\d\.]+([\w\d\.]+)?)}
|
|
||||||
name, version = $1, $2
|
|
||||||
"#{name.to_s} (v#{version.to_s})"
|
|
||||||
when /pryrc/
|
|
||||||
"~/.pryrc"
|
|
||||||
else
|
else
|
||||||
"(other)"
|
case Pry::Method(block).source_file
|
||||||
|
when %r{/pry/.*_commands/(.*).rb}
|
||||||
|
$1.capitalize.gsub(/_/, " ")
|
||||||
|
when %r{(pry-\w+)-([\d\.]+([\w\d\.]+)?)}
|
||||||
|
name, version = $1, $2
|
||||||
|
"#{name.to_s} (v#{version.to_s})"
|
||||||
|
when /pryrc/
|
||||||
|
"~/.pryrc"
|
||||||
|
else
|
||||||
|
"(other)"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -693,4 +693,20 @@ describe "Pry::Command" do
|
||||||
instance.command_state[/[Hh]ello-world/].my_state.should == 4
|
instance.command_state[/[Hh]ello-world/].my_state.should == 4
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'group' do
|
||||||
|
before do
|
||||||
|
@set.import Pry::DefaultCommands::Cd
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not change once it is initialized' do
|
||||||
|
@set.commands["cd"].group("-==CD COMMAND==-")
|
||||||
|
@set.commands["cd"].group.should == "Context"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be correct for default commands' do
|
||||||
|
@set.commands["cd"].group.should == "Context"
|
||||||
|
@set.commands["help"].group.should == "Help"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue