From cfae8a8302f06a84196700138d7ddbb25e91ea31 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 31 Dec 2009 14:32:39 -0500 Subject: Added UserInterface and other improved abstractions for command handling --- libbe/command/status.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'libbe/command/status.py') diff --git a/libbe/command/status.py b/libbe/command/status.py index 323963a..57a44aa 100644 --- a/libbe/command/status.py +++ b/libbe/command/status.py @@ -27,20 +27,23 @@ class Status (libbe.command.Command): >>> import sys >>> import libbe.bugdir >>> bd = libbe.bugdir.SimpleBugDir(memory=False) - >>> cmd = Status() + >>> io = libbe.command.StringInputOutput() + >>> io.stdout = sys.stdout + >>> ui = libbe.command.UserInterface(io=io) + >>> ui.storage_callbacks.set_bugdir(bd) + >>> cmd = Status(ui=ui) >>> cmd._storage = bd.storage - >>> cmd._setup_io = lambda i_enc,o_enc : None - >>> cmd.stdout = sys.stdout >>> bd.bug_from_uuid('a').status 'open' - >>> ret = cmd.run(args=['closed', '/a']) + >>> ret = ui.run(cmd, args=['closed', '/a']) >>> bd.flush_reload() >>> bd.bug_from_uuid('a').status 'closed' - >>> ret = cmd.run(args=['none', '/a']) + >>> ret = ui.run(cmd, args=['none', '/a']) Traceback (most recent call last): UserError: Invalid status level: none + >>> ui.cleanup() >>> bd.cleanup() """ name = 'status' -- cgit