diff options
Diffstat (limited to 'becommands/target.py')
-rw-r--r-- | becommands/target.py | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/becommands/target.py b/becommands/target.py index dce100f..c83ffa7 100644 --- a/becommands/target.py +++ b/becommands/target.py @@ -15,36 +15,38 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Show or change a bug's target for fixing""" -from libbe import cmdutil, bugdir +from libbe import cmdutil, bugdir, settings_object __desc__ = __doc__ -def execute(args): +def execute(args, test=False): """ >>> import os >>> bd = bugdir.simple_bug_dir() >>> os.chdir(bd.root) - >>> execute(["a"]) + >>> execute(["a"], test=True) No target assigned. - >>> execute(["a", "tomorrow"]) - >>> execute(["a"]) + >>> execute(["a", "tomorrow"], test=True) + >>> execute(["a"], test=True) tomorrow - >>> execute(["a", "none"]) - >>> execute(["a"]) + >>> execute(["a", "none"], test=True) + >>> execute(["a"], test=True) No target assigned. """ - options, args = get_parser().parse_args(args) - assert(len(args) in (0, 1, 2)) - if len(args) == 0: - print help() - return - bd = bugdir.BugDir(from_disk=True) + parser = get_parser() + options, args = parser.parse_args(args) + cmdutil.default_complete(options, args, parser, + bugid_args={0: lambda bug : bug.active==True}) + if len(args) not in (1, 2): + raise cmdutil.UsageError + bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) bug = bd.bug_from_shortname(args[0]) if len(args) == 1: - if bug.target is None: + if bug.target is None or bug.target is settings_object.EMPTY: print "No target assigned." else: print bug.target - elif len(args) == 2: + else: + assert len(args) == 2 if args[1] == "none": bug.target = None else: |