summaryrefslogtreecommitdiffstats
path: root/formats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2015-12-01 14:47:11 +0100
committerJan Pokorný <jpokorny@redhat.com>2015-12-17 23:35:32 +0100
commite4936b2023627e3f122d9da084cec65980418328 (patch)
tree16c55beabf809937312dcb5546e92dd799dc2788 /formats
parent07dd44023281b514b24b0dd8c4a6584e5abfb7c9 (diff)
downloadclufter-e4936b2023627e3f122d9da084cec65980418328.tar.gz
clufter-e4936b2023627e3f122d9da084cec65980418328.tar.xz
clufter-e4936b2023627e3f122d9da084cec65980418328.zip
formats/command[separated]: option + 1 arg as a general assumption
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'formats')
-rw-r--r--formats/command.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/formats/command.py b/formats/command.py
index b92a5c8..087e224 100644
--- a/formats/command.py
+++ b/formats/command.py
@@ -60,16 +60,20 @@ class command(SimpleFormat):
while merged:
i = merged.pop()
if acc == ['--'] or i is None or i.startswith('-') and i != '-':
- if acc:
+ if not acc:
+ pass
+ elif acc[0].startswith('-'):
+ # expect that, by convention, option takes at most 1 arg
+ ret.extend(filter(bool, (tuple(acc[:2]), tuple(acc[2:]))))
+ else:
ret.append(tuple(acc))
acc = [] if i is None else [i]
elif self._dict.get('magic_split', False):
acc.extend(i.split('::')) # magic "::"-split
- merged.append(None)
else:
acc.append(i)
- # expect that, by convention, option takes at most a single argument
- ret.extend(filter(bool, (tuple(acc[:2]), tuple(acc[2:]))))
+ if acc and not merged:
+ merged.append(None) # mark terminal acc -> ret propagation
return ret
@SimpleFormat.producing(MERGED, protect=True)