From 60dcbc2265eadecb90de2094d92f17c5af8f934f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 27 Sep 2012 03:36:40 -0400 Subject: [PATCH] Support command-line overrides. --- irkbot.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/irkbot.py b/irkbot.py index dfe8b68..3abfbc4 100755 --- a/irkbot.py +++ b/irkbot.py @@ -33,6 +33,10 @@ # short -> first 12 chars of hex ID # describe = -> describe relative to last tag, falling back to short # The default is 'describe'. +# +# Any of these variables can be overridden with a command-line argument that +# is a key=value pair. For example "project=foobar" will force the project +# name to foobar, regardless of what the git configuration says. # The default location of the irker proxy, if the project configuration # does not override it. @@ -147,6 +151,22 @@ if __name__ == "__main__": # Someday we'll have extractors for several version-control systems extractor = GitExtractor(project) + # Make command-line overrides possible. + # Each argument of the form = can override the + # member of the extractor class. + booleans = ["tcp"] + for tok in arguments: + for key in extractor.__dict__: + if tok.startswith(key + "="): + val = tok[len(key)+1:] + if key in booleans: + if val.lower == "true": + setattr(extractor, key, True) + elif val.lower == "false": + setattr(extractor, key, False) + else: + setattr(extractor, key, val) + # By default, the channel list includes the freenode #commits list if not extractor.channels: extractor.channels = "irc://chat.freenode.net/%s,irc://chat.freenode.net/#commits" % extractor.project -- 2.26.2