self._shortopts += f + (has_parm and ':' or '')
flagl_nice.append('-' + f)
else:
+ assert(not f.startswith('no-')) # supported implicitly
self._longopts.append(f + (has_parm and '=' or ''))
+ self._longopts.append('no-' + f)
flagl_nice.append('--' + f)
flags_nice = ', '.join(flagl_nice)
if has_parm:
k = k[1:]
if k in ['h', '?', 'help']:
self.usage()
- k = self._aliases[k]
- if not self._hasparms[k]:
- assert(v == '')
- opt[k] = (opt._opts.get(k) or 0) + 1
+ if k.startswith('no-'):
+ k = self._aliases[k[3:]]
+ opt[k] = None
else:
- opt[k] = v
+ k = self._aliases[k]
+ if not self._hasparms[k]:
+ assert(v == '')
+ opt[k] = (opt._opts.get(k) or 0) + 1
+ else:
+ opt[k] = v
for (f1,f2) in self._aliases.items():
opt[f1] = opt[f2]
return (opt,flags,extra)
WVPASSEQ(extra, ['hanky'])
WVPASSEQ((opt.t, opt.q, opt.p, opt.l, opt.onlylong,
opt.neveropt), (3,1,7,'19',1,None))
+ (opt,flags,extra) = o.parse(['--onlylong', '-t', '--no-onlylong'])
+ WVPASSEQ((opt.t, opt.q, opt.onlylong), (1, None, None))