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