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,
34
28
from bzrlib.ui import CLIUIFactory
61
55
def prompt(self, prompt):
62
56
"""Emit prompt on the CLI."""
63
self.stdout.write(prompt)
57
self.stdout.write(prompt + "? [y/n]:")
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)
65
82
def nested_progress_bar(self):
66
83
"""Return a nested progress bar.
69
86
may return a tty or dots bar depending on the terminal.
71
88
if self._progress_bar_stack is None:
72
self._progress_bar_stack = progress.ProgressBarStack(
89
self._progress_bar_stack = bzrlib.progress.ProgressBarStack(
73
90
klass=self._bar_type)
74
91
return self._progress_bar_stack.get_nested()