1316
1316
(['status'], {'all': True})
1317
1317
>>> parse_args('commit --message=biter'.split())
1318
1318
(['commit'], {'message': u'biter'})
1319
>>> parse_args('log -r 500'.split())
1320
(['log'], {'revision': 500})
1321
>>> parse_args('log -r500:600'.split())
1322
(['log'], {'revision': [500, 600]})
1323
>>> parse_args('log -vr500:600'.split())
1324
(['log'], {'verbose': True, 'revision': [500, 600]})
1325
>>> parse_args('log -rv500:600'.split()) #the r takes an argument
1326
Traceback (most recent call last):
1328
ValueError: invalid literal for int(): v500
1338
1348
bailout('unknown long option %r' % a)
1340
1350
shortopt = a[1:]
1341
if shortopt not in SHORT_OPTIONS:
1342
bailout('unknown short option %r' % a)
1343
optname = SHORT_OPTIONS[shortopt]
1351
if shortopt in SHORT_OPTIONS:
1352
# Multi-character options must have a space to delimit
1354
optname = SHORT_OPTIONS[shortopt]
1356
# Single character short options, can be chained,
1357
# and have their value appended to their name
1359
if shortopt not in SHORT_OPTIONS:
1360
# We didn't find the multi-character name, and we
1361
# didn't find the single char name
1362
bailout('unknown short option %r' % a)
1363
optname = SHORT_OPTIONS[shortopt]
1366
# There are extra things on this option
1367
# see if it is the value, or if it is another
1369
optargfn = OPTIONS[optname]
1370
if optargfn is None:
1371
# This option does not take an argument, so the
1372
# next entry is another short option, pack it back
1374
argv.insert(0, '-' + a[2:])
1376
# This option takes an argument, so pack it
1345
1380
if optname in opts:
1346
1381
# XXX: Do we ever want to support this, e.g. for -r?