diff options
author | Aaron Bentley <abentley@panoramicfeedback.com> | 2005-03-11 19:28:15 +0000 |
---|---|---|
committer | Aaron Bentley <abentley@panoramicfeedback.com> | 2005-03-11 19:28:15 +0000 |
commit | d1a7b4f7f14aded08d3e9da2da1b155b2da70c53 (patch) | |
tree | 7d571d81e68c1fffd8e3a48eb899fd0fde1a8b38 /libbe | |
parent | f254781274f35c485befb4f6acedb8fb8d1f797b (diff) | |
download | bugseverywhere-d1a7b4f7f14aded08d3e9da2da1b155b2da70c53.tar.gz |
Added exceptions for missing commands, handled -, plugin command exec
Diffstat (limited to 'libbe')
-rw-r--r-- | libbe/cmdutil.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py index 77f0dfb..891e273 100644 --- a/libbe/cmdutil.py +++ b/libbe/cmdutil.py @@ -51,10 +51,17 @@ def bug_summary(bug, bugs): bug.summary) def iter_commands(): - return plugin.iter_plugins("becommands") + for name, module in plugin.iter_plugins("becommands"): + yield name.replace("_", "-"), module + +def get_command(command_name): + cmd = plugin.get_plugin("becommands", command_name.replace("-", "_")) + if cmd is None: + raise UserError("Unknown command %s" % command_name) + return cmd def execute(cmd, args): - return plugin.get_plugin("becommands", cmd).execute(args) + return get_command(cmd).execute(args) def help(cmd, args): - return plugin.get_plugin("becommands", cmd).help() + return get_command(cmd).help() |