1 # Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc.
2 # W. Trevor King <wking@drexel.edu>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with this program; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 """Create a new bug"""
18 from libbe import cmdutil, bugdir
22 def execute(args, manipulate_encodings=True):
25 >>> from libbe import bug
26 >>> bd = bugdir.SimpleBugDir()
28 >>> bug.uuid_gen = lambda: "X"
29 >>> execute (["this is a test",], manipulate_encodings=False)
32 >>> bug = bd.bug_from_uuid("X")
35 >>> bug.time <= int(time.time())
37 >>> print bug.severity
39 >>> bug.target == None
44 options, args = parser.parse_args(args)
45 cmdutil.default_complete(options, args, parser)
47 raise cmdutil.UsageError("Please supply a summary message")
48 bd = bugdir.BugDir(from_disk=True,
49 manipulate_encodings=manipulate_encodings)
50 if args[0] == '-': # read summary from stdin
51 summary = sys.stdin.readline()
54 bug = bd.new_bug(summary=summary.strip())
55 if options.reporter != None:
56 bug.reporter = options.reporter
58 bug.reporter = bug.creator
59 if options.assigned != None:
60 bug.assigned = options.assigned
61 elif bd.default_assignee != None:
62 bug.assigned = bd.default_assignee
63 print "Created bug with ID %s" % bd.bug_shortname(bug)
66 parser = cmdutil.CmdOptionParser("be new SUMMARY")
67 parser.add_option("-r", "--reporter", metavar="REPORTER", dest="reporter",
68 help="The user who reported the bug", default=None)
69 parser.add_option("-a", "--assigned", metavar="ASSIGNED", dest="assigned",
70 help="The developer in charge of the bug", default=None)
74 Create a new bug, with a new ID. The summary specified on the
75 commandline is a string (only one line) that describes the bug briefly
76 or "-", in which case the string will be read from stdin.
80 return get_parser().help_str() + longhelp