aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbe74
-rw-r--r--becommands/__init__.py (renamed from commands/__init__.py)0
-rw-r--r--becommands/close.py4
-rw-r--r--becommands/list.py18
-rw-r--r--becommands/new.py13
-rw-r--r--becommands/open.py4
-rw-r--r--becommands/set_root.py6
-rw-r--r--becommands/severity.py (renamed from commands/severity.py)0
-rw-r--r--becommands/show.py9
9 files changed, 71 insertions, 57 deletions
diff --git a/be b/be
index 5c04906..3aa8d38 100755
--- a/be
+++ b/be
@@ -4,11 +4,16 @@ from libbe.bugdir import tree_root, create_bug_dir
from libbe import names
import sys
import os
-import commands
-import commands.severity
+import becommands.severity
+import becommands.list
+import becommands.show
+import becommands.set_root
+import becommands.new
+import becommands.close
+import becommands.open
__doc__ = """Bugs Everywhere - Distributed bug tracking
-Supported commands
+Supported becommands
set-root: assign the root directory for bug tracking
new: Create a new bug
list: list bugs
@@ -17,56 +22,11 @@ Supported commands
open: re-open a bug
severity: %s
-Unimplemented commands
+Unimplemented becommands
comment: append a comment to a bug
-""" % commands.severity.__desc__
+""" % becommands.severity.__desc__
-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
- all_bugs = list(tree_root(os.getcwd()).list())
- bugs = [b for b in all_bugs if filter(b) ]
- if len(bugs) == 0:
- print "No matching bugs found"
- for bug in bugs:
- print bug_summary(bug, all_bugs)
-def show_bug(args):
- bug_dir = tree_root(os.getcwd())
- if len(args) !=1:
- raise UserError("Please specify a bug id.")
- print bug_summary(get_bug(args[0], bug_dir), list(bug_dir.list()))
-
-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.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__
@@ -74,13 +34,13 @@ else:
try:
try:
cmd = {
- "list": list_bugs,
- "show": show_bug,
- "set-root": set_root,
- "new": new_bug,
- "close": close_bug,
- "open": open_bug,
- "severity": commands.severity.execute,
+ "list": becommands.list.execute,
+ "show": becommands.show.execute,
+ "set-root": becommands.set_root.execute,
+ "new": becommands.new.execute,
+ "close": becommands.close.execute,
+ "open": becommands.open.execute,
+ "severity": becommands.severity.execute,
}[sys.argv[1]]
except KeyError, e:
raise UserError("Unknown command \"%s\"" % e.args[0])
diff --git a/commands/__init__.py b/becommands/__init__.py
index e69de29..e69de29 100644
--- a/commands/__init__.py
+++ b/becommands/__init__.py
diff --git a/becommands/close.py b/becommands/close.py
new file mode 100644
index 0000000..184e2e1
--- /dev/null
+++ b/becommands/close.py
@@ -0,0 +1,4 @@
+from libbe import cmdutil
+def execute(args):
+ assert(len(args) == 1)
+ cmdutil.get_bug(args[0]).status = "closed"
diff --git a/becommands/list.py b/becommands/list.py
new file mode 100644
index 0000000..b608629
--- /dev/null
+++ b/becommands/list.py
@@ -0,0 +1,18 @@
+from libbe import bugdir, cmdutil
+import os
+def execute(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
+ all_bugs = list(bugdir.tree_root(os.getcwd()).list())
+ bugs = [b for b in all_bugs if filter(b) ]
+ if len(bugs) == 0:
+ print "No matching bugs found"
+ for bug in bugs:
+ print cmdutil.bug_summary(bug, all_bugs)
diff --git a/becommands/new.py b/becommands/new.py
new file mode 100644
index 0000000..2e78524
--- /dev/null
+++ b/becommands/new.py
@@ -0,0 +1,13 @@
+from libbe import bugdir, cmdutil, names
+def execute(args):
+ if len(args) != 1:
+ raise cmdutil.UserError("Please supply a summary message")
+ dir = bugdir.tree_root(".")
+ bugs = (dir.list())
+ bug = dir.new_bug()
+ bug.creator = names.creator()
+ bug.severity = "minor"
+ bug.status = "open"
+ bug.summary = args[0]
+
+
diff --git a/becommands/open.py b/becommands/open.py
new file mode 100644
index 0000000..db89035
--- /dev/null
+++ b/becommands/open.py
@@ -0,0 +1,4 @@
+from libbe import cmdutil
+def execute(args):
+ assert(len(args) == 1)
+ cmdutil.get_bug(args[0]).status = "open"
diff --git a/becommands/set_root.py b/becommands/set_root.py
new file mode 100644
index 0000000..bf1d495
--- /dev/null
+++ b/becommands/set_root.py
@@ -0,0 +1,6 @@
+from libbe import bugdir, cmdutil
+
+def execute(args):
+ if len(args) != 1:
+ raise cmdutil.UserError("Please supply a directory path")
+ bugdir.create_bug_dir(args[0])
diff --git a/commands/severity.py b/becommands/severity.py
index a421dd2..a421dd2 100644
--- a/commands/severity.py
+++ b/becommands/severity.py
diff --git a/becommands/show.py b/becommands/show.py
new file mode 100644
index 0000000..8b38386
--- /dev/null
+++ b/becommands/show.py
@@ -0,0 +1,9 @@
+from libbe import bugdir, cmdutil
+import os
+
+def execute(args):
+ bug_dir = bugdir.tree_root(os.getcwd())
+ if len(args) !=1:
+ raise cmdutil.UserError("Please specify a bug id.")
+ print cmdutil.bug_summary(cmdutil.get_bug(args[0], bug_dir),
+ list(bug_dir.list()))