#!/usr/bin/env python
-"""Bugs Everywhere - Distributed bug tracking
+# Copyright (C) 2005-2012 Aaron Bentley <abentley@panoramicfeedback.com>
+# Chris Ball <cjb@laptop.org>
+# Gianluca Montecchi <gian@grys.it>
+# Oleg Romanyshyn <oromanyshyn@panoramicfeedback.com>
+# W. Trevor King <wking@tremily.us>
+#
+# This file is part of Bugs Everywhere.
+#
+# Bugs Everywhere is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 2 of the License, or (at your option) any
+# later version.
+#
+# Bugs Everywhere is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Bugs Everywhere. If not, see <http://www.gnu.org/licenses/>.
-be list: list bugs
-be status: view or set the status of a bug
-be comment: append a comment to a bug
-be set-root: assign the root directory for bug tracking
-"""
-from libbe.cmdutil import *
-from libbe.bugdir import tree_root, create_bug_dir
-from libbe import names
import sys
-import os
+import libbe.ui.command_line
-def list_bugs(args):
- active = True
- severity = ("minor", "serious", "critical", "fatal")
- def filter(bug):
- if active is not None:
- if bug.active != active:
- return False
- if bug.severity not in severity:
- return False
- return True
-
- bugs = [b for b in tree_root(os.getcwd()).list() if filter(b) ]
- if len(bugs) == 0:
- print "No matching bugs found"
- for bug in bugs:
- target = bug.target
- if target is None:
- target = ""
- else:
- target = " target: %s" % target
- print "id: %s severity: %s%s\n%s\n" % (unique_name(bug, bugs),
- bug.severity, target, bug.summary)
-def set_root(args):
- if len(args) != 1:
- raise UserError("Please supply a directory path")
- create_bug_dir(args[0])
-
-def new_bug(args):
- if len(args) != 1:
- raise UserError("Please supply a summary message")
- dir = tree_root(".")
- bugs = (dir.list())
- bug = dir.new_bug()
- bug.creator = names.creator()
- bug.name = names.friendly_name(bugs, bug.creator)
- bug.severity = "minor"
- bug.status = "open"
- bug.summary = args[0]
-
-def close_bug(args):
- assert(len(args) == 1)
- get_bug(args[0], tree_root('.')).status = "closed"
-
-def open_bug(args):
- assert(len(args) == 1)
- get_bug(args[0], tree_root('.')).status = "open"
-
-if len(sys.argv) == 1:
- print __doc__
-else:
- try:
- try:
- cmd = {
- "list": list_bugs,
- "set-root": set_root,
- "new": new_bug,
- "close": close_bug,
- "open": open_bug,
- }[sys.argv[1]]
- except KeyError, e:
- raise UserError("Unknown command \"%s\"" % e.args[0])
- cmd(sys.argv[2:])
- except UserError, e:
- print e
- sys.exit(1)
+sys.exit(libbe.ui.command_line.main())