From 0b2305a7460011f99bc2c886248a4a124ac3d285 Mon Sep 17 00:00:00 2001 From: Andrei Date: Thu, 24 Nov 2016 07:56:25 -0600 Subject: [PATCH] bugfix - fix flag parsing be super derp --- disco/bot/parser.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/disco/bot/parser.py b/disco/bot/parser.py index 1df5e9f..d6f38db 100644 --- a/disco/bot/parser.py +++ b/disco/bot/parser.py @@ -165,20 +165,19 @@ class ArgumentSet(object): parsed = {} flags = {i.name: i for i in self.args if i.flag} - if not flags: - return parsed + if flags: + new_rawargs = [] - new_rawargs = [] + for offset, raw in enumerate(rawargs): + if raw.startswith('-'): + raw = raw.lstrip('-') + if raw in flags: + parsed[raw] = True + continue + new_rawargs.append(raw) - for offset, raw in enumerate(rawargs): - if raw.startswith('-'): - raw = raw.lstrip('-') - if raw in flags: - parsed[raw] = True - continue - new_rawargs.append(raw) + rawargs = new_rawargs - rawargs = new_rawargs for index, arg in enumerate((arg for arg in self.args if not arg.flag)): if not arg.required and index + arg.true_count > len(rawargs): continue