def Display(self, unused_args, result): if result.accounts: lp = console_io.ListPrinter('Credentialed accounts:') lp.Print([account + (' (active)' if account == result.active_account else '') for account in result.accounts]) log.err.Print(textwrap.dedent(""" To set the active account, run: $ gcloud config set account ``ACCOUNT'' """)) else: log.err.Print(textwrap.dedent("""\ No credentialed accounts. To login, run: $ gcloud auth login ``ACCOUNT'' """))
def ConstructList(title, items): """Returns a string displaying the items and a title.""" buf = cStringIO.StringIO() printer = console_io.ListPrinter(title) printer.Print(sorted(set(items)), output_stream=buf) return buf.getvalue()
def ConstructList(title, items): buf = cStringIO.StringIO() printer = console_io.ListPrinter(title) printer.Print(items, output_stream=buf) return buf.getvalue()