Commits

Jason R. Coombs  committed 110bd41

Added support for multiple config files

  • Participants
  • Parent commits efa9286
  • Tags 1105.6

Comments (0)

Files changed (2)

 * Added support for logging leave events as well as join events.
 * Added a new ``@on_leave`` decorator, suitable for implementing custom
   handlers for leave events.
+* ``pmxbot`` command now optionally accepts multiple config files.
 
 1105.5
 ======

File pmxbot/core.py

 		return func
 	return deco
 
-def get_args():
+class ConfigMergeAction(argparse.Action):
+	def __call__(self, parser, namespace, values, option_string=None):
+		def merge_dicts(a, b):
+			a.update(b)
+			return a
+		setattr(namespace, self.dest, reduce(merge_dicts, values))
+
+def get_args(*args, **kwargs):
 	parser = argparse.ArgumentParser()
 	parser.add_argument('config', type=pmxbot.dictlib.ConfigDict.from_yaml,
-		default={}, nargs='?')
-	return parser.parse_args()
+		default={}, nargs='*', action=ConfigMergeAction)
+	return parser.parse_args(*args, **kwargs)
 
 def run():
 	global _bot