Aka: Fix combination of required and optional arguments.

Was broken by 7f43727835 (why?)
This commit is contained in:
Valentin Lorentz 2017-08-18 18:30:22 +02:00
parent b00081f6c9
commit 5272bf3a86
2 changed files with 6 additions and 0 deletions

View File

@ -467,6 +467,7 @@ class Aka(callbacks.Plugin):
replace(tokens, lambda s: dollarRe.sub(regexpReplace, s)) replace(tokens, lambda s: dollarRe.sub(regexpReplace, s))
if biggestAt: if biggestAt:
assert not wildcard assert not wildcard
args = args[biggestDollar:]
replace(tokens, lambda s: atRe.sub(regexpReplace, s)) replace(tokens, lambda s: atRe.sub(regexpReplace, s))
if wildcard: if wildcard:
assert not biggestAt assert not biggestAt

View File

@ -135,6 +135,11 @@ class AkaChannelTestCase(ChannelPluginTestCase):
self.assertResponse('myrepr foo', '"foo"') self.assertResponse('myrepr foo', '"foo"')
self.assertResponse('myrepr ""', '""') self.assertResponse('myrepr ""', '""')
def testRequiredAndOptional(self):
self.assertNotError('aka add reqopt "echo req=$1, opt=@1"')
self.assertResponse('reqopt foo bar', 'req=foo, opt=bar')
self.assertResponse('reqopt foo', 'req=foo, opt=')
def testNoExtraSpaces(self): def testNoExtraSpaces(self):
self.assertNotError('aka add foo "action takes $1\'s money"') self.assertNotError('aka add foo "action takes $1\'s money"')
self.assertResponse('foo bar', '\x01ACTION takes bar\'s money\x01') self.assertResponse('foo bar', '\x01ACTION takes bar\'s money\x01')