From d2eff8fdaf0d535bacd30be835145302c418df8f Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 22 Sep 2003 10:22:06 +0000 Subject: [PATCH] RFE #810366: --private option to MiscCommands.list. --- src/MiscCommands.py | 15 ++++++++++----- test/test_MiscCommands.py | 9 ++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/MiscCommands.py b/src/MiscCommands.py index 098ebdb13..cb0c7c31d 100755 --- a/src/MiscCommands.py +++ b/src/MiscCommands.py @@ -81,16 +81,21 @@ class MiscCommands(callbacks.Privmsg): irc.queueMsg(callbacks.reply(msg, s)) def list(self, irc, msg, args): - """[] + """[--private] [] 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() if not name: 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() irc.reply(msg, ', '.join(names)) else: @@ -106,7 +111,7 @@ class MiscCommands(callbacks.Privmsg): irc.reply(msg, ', '.join(commands)) return 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): """ diff --git a/test/test_MiscCommands.py b/test/test_MiscCommands.py index 789bdf24c..3d4dae99e 100644 --- a/test/test_MiscCommands.py +++ b/test/test_MiscCommands.py @@ -32,7 +32,7 @@ from test import * class MiscCommandsTestCase(ChannelPluginTestCase, PluginDocumentation): - plugins = ('MiscCommands', 'Utilities', 'ChannelDB') + plugins = ('MiscCommands', 'Utilities', 'ChannelDB', 'Ctcp') def testReplyWhenNotCommand(self): try: conf.replyWhenNotCommand = True @@ -71,6 +71,13 @@ class MiscCommandsTestCase(ChannelPluginTestCase, PluginDocumentation): def testList(self): 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): self.assertNotError('bug')