aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/command/set.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2012-08-29 23:26:17 -0400
committerW. Trevor King <wking@tremily.us>2012-08-29 23:31:03 -0400
commit4db1a045a0606bead191a563abc54dfa8352efe0 (patch)
tree51c891d731555340ffd4432cd889fb67795ae1b6 /libbe/command/set.py
parent5a32d82284e54facf2f5dcb03ba37afe3805a609 (diff)
downloadbugseverywhere-4db1a045a0606bead191a563abc54dfa8352efe0.tar.gz
Rewrite commands to use bugdirs instead of a single bugdir.
The bulk of the work is in regard to XML, with new BugDir.xml and .from_xml methods to support the new <bugdir> entity. I also split the guts import_xml's ._run method into sub-methods to make the import logic more obvious.
Diffstat (limited to 'libbe/command/set.py')
-rw-r--r--libbe/command/set.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/libbe/command/set.py b/libbe/command/set.py
index f635faa..e575b08 100644
--- a/libbe/command/set.py
+++ b/libbe/command/set.py
@@ -57,6 +57,15 @@ class Set (libbe.command.Command):
def __init__(self, *args, **kwargs):
libbe.command.Command.__init__(self, *args, **kwargs)
+ self.options.extend([
+ libbe.command.Option(name='bugdir', short_name='b',
+ help='Short bugdir UUID to act on. You '
+ 'only need to set this if you have multiple bugdirs in '
+ 'your repository.',
+ arg=libbe.command.Argument(
+ name='bugdir', metavar='ID', default=None,
+ completion_callback=libbe.command.util.complete_bugdir_id)),
+ ])
self.args.extend([
libbe.command.Argument(
name='setting', metavar='SETTING', optional=True,
@@ -66,7 +75,14 @@ class Set (libbe.command.Command):
])
def _run(self, **params):
- bugdir = self._get_bugdir()
+ bugdirs = self._get_bugdirs()
+ if params['bugdir']:
+ bugdir = bugdirs[bugdir]
+ elif len(bugdirs) == 1:
+ bugdir = bugdirs.values()[0]
+ else:
+ raise libbe.command.UserError(
+ 'Ambiguous bugdir {}'.format(sorted(bugdirs.values())))
if params['setting'] == None:
keys = bugdir.settings_properties
keys.sort()