[rfc] UIFactory.is_interactive()
Martin Pool
mbp at canonical.com
Tue Nov 24 03:28:52 GMT 2009
For background,
https://code.launchpad.net/~bialix/bzr/shelve-no-tty/+merge/14905
wants to make 'bzr shelve' not ask any interactive questions if there
is no tty.
More generally I think the ui factory should be able to tell
application code whether it can interact with the user or not. For a
text ui, this would probably correlate to having a tty; for server
things it will always be false; for guis presumably always true. Then
we can have code generally doing
if ui_factory.is_interactive():
if not ui_factory.get_boolean("really delete everything?"):
return
delete_everything()
This somewhat violates "don't look before you leap" but it's probably
worthwhile to avoid thinking about interactive stuff before you do it.
I can imagine later having an option to say "yes, but never be
interactive" (I guess --batch).
This is similar to but distinct from having a real terminal; on a very
dumb terminal (eg under emacs) you might want to read input but not to
show progress.
I think this is also distinct from an actual --interactive or -i
option, which would mean "even more interactive than usual", like
asking to commit individual files. Though possibly that should go
into ui_factory.is_super_interactive() (or a better name.)
Maybe it should be .can_interact().
This could do interesting things for testing: testing some commands
both ways, or making sure that for the base case commands don't need
to provide any input.
--
Martin <http://launchpad.net/~mbp/>
More information about the bazaar
mailing list