mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 11:12:47 +01:00
rest should require args unless indicated otherwise. Currently, we can't indicate otherwise, but that's because we haven't had a need for it yet.
This commit is contained in:
parent
54db030707
commit
d280387518
@ -622,12 +622,15 @@ class context(object):
|
|||||||
|
|
||||||
class rest(context):
|
class rest(context):
|
||||||
def __call__(self, irc, msg, args, state):
|
def __call__(self, irc, msg, args, state):
|
||||||
original = args[:]
|
if args:
|
||||||
args[:] = [' '.join(args)]
|
original = args[:]
|
||||||
try:
|
args[:] = [' '.join(args)]
|
||||||
super(rest, self).__call__(irc, msg, args, state)
|
try:
|
||||||
except Exception, e:
|
super(rest, self).__call__(irc, msg, args, state)
|
||||||
args[:] = original
|
except Exception, e:
|
||||||
|
args[:] = original
|
||||||
|
else:
|
||||||
|
raise callbacks.ArgumentError
|
||||||
|
|
||||||
# additional means: Look for this (and make sure it's of this type). If
|
# additional means: Look for this (and make sure it's of this type). If
|
||||||
# there are no arguments for us to check, then use our default.
|
# there are no arguments for us to check, then use our default.
|
||||||
|
@ -57,6 +57,10 @@ class CommandsTestCase(SupyTestCase):
|
|||||||
def testRestHandling(self):
|
def testRestHandling(self):
|
||||||
self.assertState([rest(None)], ['foo', 'bar', 'baz'], ['foo bar baz'])
|
self.assertState([rest(None)], ['foo', 'bar', 'baz'], ['foo bar baz'])
|
||||||
|
|
||||||
|
def testRestRequiresArgs(self):
|
||||||
|
self.assertRaises(callbacks.ArgumentError,
|
||||||
|
self.assertState, [rest('something')], [], ['asdf'])
|
||||||
|
|
||||||
def testOptional(self):
|
def testOptional(self):
|
||||||
spec = [optional('int', 999), None]
|
spec = [optional('int', 999), None]
|
||||||
self.assertState(spec, ['12', 'foo'], [12, 'foo'])
|
self.assertState(spec, ['12', 'foo'], [12, 'foo'])
|
||||||
|
Loading…
Reference in New Issue
Block a user