19
19
"""Text UI, write output to the console.
24
from bzrlib.lazy_import import lazy_import
25
lazy_import(globals(), """
25
import bzrlib.progress
26
from bzrlib.symbol_versioning import (deprecated_method,
28
34
from bzrlib.ui import CLIUIFactory
55
61
def prompt(self, prompt):
56
62
"""Emit prompt on the CLI."""
57
self.stdout.write(prompt + "? [y/n]:")
63
self.stdout.write(prompt)
59
@deprecated_method(zero_eight)
60
def progress_bar(self):
61
"""See UIFactory.nested_progress_bar()."""
62
# this in turn is abstract, and creates either a tty or dots
63
# bar depending on what we think of the terminal
64
return bzrlib.progress.ProgressBar()
66
def get_password(self, prompt='', **kwargs):
67
"""Prompt the user for a password.
69
:param prompt: The prompt to present the user
70
:param kwargs: Arguments which will be expanded into the prompt.
71
This lets front ends display different things if
73
:return: The password string, return None if the user
76
prompt = (prompt % kwargs).encode(sys.stdout.encoding, 'replace')
78
# There's currently no way to say 'i decline to enter a password'
79
# as opposed to 'my password is empty' -- does it matter?
80
return getpass.getpass(prompt)
82
65
def nested_progress_bar(self):
83
66
"""Return a nested progress bar.
86
69
may return a tty or dots bar depending on the terminal.
88
71
if self._progress_bar_stack is None:
89
self._progress_bar_stack = bzrlib.progress.ProgressBarStack(
72
self._progress_bar_stack = progress.ProgressBarStack(
90
73
klass=self._bar_type)
91
74
return self._progress_bar_stack.get_nested()