[Pkg-bazaar-commits] ./bzr/unstable r17: allow --option=ARG syntax
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:25:04 UTC 2009
------------------------------------------------------------
revno: 17
committer: mbp at sourcefrog.net
timestamp: Wed 2005-03-09 18:40:07 +1100
message:
allow --option=ARG syntax
modified:
bzr.py
-------------- next part --------------
=== modified file 'bzr.py'
--- a/bzr.py 2005-03-09 07:03:02 +0000
+++ b/bzr.py 2005-03-09 07:40:07 +0000
@@ -553,6 +553,8 @@
([], {'version': True})
>>> parse_args('bzr status --all'.split())
(['status'], {'all': True})
+ >>> parse_args('bzr commit --message=biter'.split())
+ (['commit'], {'message': u'biter'})
"""
args = []
opts = {}
@@ -563,9 +565,13 @@
while it:
a = it.next()
if a[0] == '-':
+ optarg = None
if a[1] == '-':
mutter(" got option %r" % a)
- optname = a[2:]
+ if '=' in a:
+ optname, optarg = a[2:].split('=', 1)
+ else:
+ optname = a[2:]
if optname not in OPTIONS:
bailout('unknown long option %r' % a)
else:
@@ -577,17 +583,20 @@
if optname in opts:
# XXX: Do we ever want to support this, e.g. for -r?
bailout('repeated option %r' % a)
+
optargfn = OPTIONS[optname]
if optargfn:
- if not it:
- bailout('option %r needs an argument' % a)
- opts[optname] = optargfn(it.next())
+ if optarg == None:
+ if not it:
+ bailout('option %r needs an argument' % a)
+ else:
+ optarg = it.next()
+ opts[optname] = optargfn(optarg)
mutter(" option argument %r" % opts[optname])
else:
- # takes no option argument
+ if optarg != None:
+ bailout('option %r takes no argument' % optname)
opts[optname] = True
- elif a[:1] == '-':
- bailout('unknown short option %r' % a)
else:
args.append(a)
More information about the Pkg-bazaar-commits
mailing list