RFE #810366: --private option to MiscCommands.list.

This commit is contained in:
Jeremy Fincher 2003-09-22 10:22:06 +00:00
parent 3a329b04f9
commit d2eff8fdaf
2 changed files with 18 additions and 6 deletions

View File

@ -81,16 +81,21 @@ class MiscCommands(callbacks.Privmsg):
irc.queueMsg(callbacks.reply(msg, s)) irc.queueMsg(callbacks.reply(msg, s))
def list(self, irc, msg, args): def list(self, irc, msg, args):
"""[<module name>] """[--private] [<module name>]
Lists the commands available in the given plugin. If no plugin is Lists the commands available in the given plugin. If no plugin is
given, lists the public plugins available. given, lists the public plugins available. If --private is given,
lists all commands, not just the public ones.
""" """
name = privmsgs.getArgs(args, needed=0, optional=1) (optlist, rest) = getopt.getopt(args, '', ['private'])
for (option, argument) in optlist:
if option == '--private':
evenPrivate = True
name = privmsgs.getArgs(rest, needed=0, optional=1)
name = name.lower() name = name.lower()
if not name: if not name:
names = [cb.name() for cb in irc.callbacks names = [cb.name() for cb in irc.callbacks
if hasattr(cb, 'public') and cb.public] if evenPrivate or hasattr(cb, 'public') and cb.public]
names.sort() names.sort()
irc.reply(msg, ', '.join(names)) irc.reply(msg, ', '.join(names))
else: else:
@ -106,7 +111,7 @@ class MiscCommands(callbacks.Privmsg):
irc.reply(msg, ', '.join(commands)) irc.reply(msg, ', '.join(commands))
return return
irc.error(msg, 'There is no plugin named %s, ' \ irc.error(msg, 'There is no plugin named %s, ' \
'or that plugin has no commands.' % name) 'or that plugin has no commands.' % name)
def help(self, irc, msg, args): def help(self, irc, msg, args):
"""<command> """<command>

View File

@ -32,7 +32,7 @@
from test import * from test import *
class MiscCommandsTestCase(ChannelPluginTestCase, PluginDocumentation): class MiscCommandsTestCase(ChannelPluginTestCase, PluginDocumentation):
plugins = ('MiscCommands', 'Utilities', 'ChannelDB') plugins = ('MiscCommands', 'Utilities', 'ChannelDB', 'Ctcp')
def testReplyWhenNotCommand(self): def testReplyWhenNotCommand(self):
try: try:
conf.replyWhenNotCommand = True conf.replyWhenNotCommand = True
@ -71,6 +71,13 @@ class MiscCommandsTestCase(ChannelPluginTestCase, PluginDocumentation):
def testList(self): def testList(self):
self.assertNotError('list MiscCommands') self.assertNotError('list MiscCommands')
self.assertNotError('list misccommands') self.assertNotError('list misccommands')
# If Ctcp changes to public, these tests will break. So if
# the next assert fails, change the plugin we test for public/private
# to some other non-public plugin.
name = 'Ctcp'
self.failIf(self.irc.getCallback(name).public)
self.assertNotRegexp('list', name)
self.assertRegexp('list --private', name)
def testBug(self): def testBug(self):
self.assertNotError('bug') self.assertNotError('bug')