f76a33
#! /usr/bin/env python3
f76a33
f76a33
from zzipdoc.match import Match
f76a33
f76a33
# use as o.optionname to check for commandline options.
f76a33
class Options:
f76a33
    var = {}
f76a33
    def __getattr__(self, name):
f76a33
        if not name in self.var: return None
f76a33
        return self.var[name]
f76a33
    def __setattr__(self, name, value):
f76a33
        self.var[name] = value
f76a33
    def scan(self, optionstring): # option-name or None
f76a33
        x = Match()
f76a33
        if optionstring & x(r"^--?(\w+)=(.*)"):
f76a33
            self.var[x[1]] = x[2] ;  return x[1]
f76a33
        if optionstring & x(r"^--?no-(\w+)$"):
f76a33
            self.var[x[1]] = "" ; return x[1]
f76a33
        if optionstring & x(r"^--?(\w+)$"):
f76a33
            self.var[x[1]] = "*"; return x[1]
f76a33
        return None
f76a33
#end Options
f76a33
f76a33
if False:
f76a33
    o = Options()
f76a33
    o.help = """
f76a33
    scans for options
f76a33
    """