mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-02 16:09:24 +01:00
Utilities: add countargs function, returns number of arguments supplied.
also add tests for it.
This commit is contained in:
parent
52b36555f4
commit
5f2d2a9c5e
@ -104,6 +104,14 @@ class Utilities(callbacks.Plugin):
|
|||||||
irc.error('%s' % (e,))
|
irc.error('%s' % (e,))
|
||||||
sample = wrap(sample, ['positiveInt', many('anything')])
|
sample = wrap(sample, ['positiveInt', many('anything')])
|
||||||
|
|
||||||
|
def countargs(self, irc, msg, args, things):
|
||||||
|
"""<arg> [<arg> ...]
|
||||||
|
|
||||||
|
Counts the arguments given.
|
||||||
|
"""
|
||||||
|
irc.reply(len(things))
|
||||||
|
countargs = wrap(countargs, [any('anything')])
|
||||||
|
|
||||||
def apply(self, irc, msg, args, command, rest):
|
def apply(self, irc, msg, args, command, rest):
|
||||||
"""<command> <text>
|
"""<command> <text>
|
||||||
|
|
||||||
|
@ -65,4 +65,9 @@ class UtilitiesTestCase(PluginTestCase):
|
|||||||
self.assertError('sample 5 moo')
|
self.assertError('sample 5 moo')
|
||||||
self.assertRegexp('sample 2 a b c', '^[a-c] [a-c]$')
|
self.assertRegexp('sample 2 a b c', '^[a-c] [a-c]$')
|
||||||
|
|
||||||
|
def testCountargs(self):
|
||||||
|
self.assertResponse('countargs a b c', '3')
|
||||||
|
self.assertResponse('countargs a "b c"', '2')
|
||||||
|
self.assertResponse('countargs', '0')
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
Loading…
Reference in New Issue
Block a user