gerrit: account: dump more details

Scrape more detailed info and allow specifying of the account name.
This helps with debugging other accounts.

BUG=None
TEST=`gerrit account vapier` shows extended info

Change-Id: Ieccdc414d933176560882fbc28bf30540d6f3feb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2673083
Tested-by: Mike Frysinger <vapier@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Bernie Thompson <bhthompson@chromium.org>
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
diff --git a/lib/gerrit.py b/lib/gerrit.py
index b7f4568..839c387 100644
--- a/lib/gerrit.py
+++ b/lib/gerrit.py
@@ -521,9 +521,9 @@
       return
     gob_util.DeleteDraft(self.host, self._to_changenum(change))
 
-  def GetAccount(self):
+  def GetAccount(self, account='self'):
     """Get information about the user account."""
-    return gob_util.GetAccount(self.host)
+    return gob_util.GetAccount(self.host, account=account)
 
 
 def GetGerritPatchInfo(patches):
diff --git a/lib/gob_util.py b/lib/gob_util.py
index dfd193c..2c7adcb 100644
--- a/lib/gob_util.py
+++ b/lib/gob_util.py
@@ -880,6 +880,6 @@
     raise GOBError(reason='Failed parsing commit time "%s"' % commit_timestr)
 
 
-def GetAccount(host):
+def GetAccount(host, account='self'):
   """Get information about the user account."""
-  return FetchUrlJson(host, 'accounts/self')
+  return FetchUrlJson(host, 'accounts/%s' % (account,))
diff --git a/scripts/gerrit.py b/scripts/gerrit.py
index bc86825..96eee8f 100644
--- a/scripts/gerrit.py
+++ b/scripts/gerrit.py
@@ -27,6 +27,7 @@
 from chromite.lib import gerrit
 from chromite.lib import gob_util
 from chromite.lib import parallel
+from chromite.lib import pformat
 from chromite.lib import terminal
 from chromite.lib import uri_lib
 from chromite.utils import memoize
@@ -801,21 +802,38 @@
     helper.UnignoreChange(cl, dryrun=opts.dryrun)
 
 
-class ActionAccount(UserAction):
-  """Get the current user account information"""
+class ActionAccount(_ActionSimpleParallelCLs):
+  """Get user account information"""
 
   COMMAND = 'account'
 
   @staticmethod
-  def __call__(opts):
+  def init_subparser(parser):
+    """Add arguments to this action's subparser."""
+    parser.add_argument('accounts', nargs='*', default=['self'],
+                        help='The accounts to query')
+
+  @classmethod
+  def __call__(cls, opts):
     """Implement the action."""
     helper, _ = GetGerrit(opts)
-    acct = helper.GetAccount()
-    if opts.json:
-      json.dump(acct, sys.stdout)
-    else:
-      print('account_id:%i  %s <%s>' %
-            (acct['_account_id'], acct['name'], acct['email']))
+
+    def print_one(header, data):
+      print(f'### {header}')
+      print(pformat.json(data, compact=opts.json).rstrip())
+
+    def task(arg):
+      detail = gob_util.FetchUrlJson(helper.host, f'accounts/{arg}/detail')
+      if not detail:
+        print(f'{arg}: account not found')
+      else:
+        print_one('detail', detail)
+        for field in ('groups', 'capabilities', 'preferences', 'sshkeys',
+                      'gpgkeys'):
+          data = gob_util.FetchUrlJson(helper.host, f'accounts/{arg}/{field}')
+          print_one(field, data)
+
+    _run_parallel_tasks(task, *opts.accounts)
 
 
 class ActionHelpAll(UserAction):