summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2016-06-28 18:29:28 +0200
committerRuben Pollan <meskio@sindominio.net>2016-07-03 16:04:41 +0200
commitff7c106ee5bd950bb87279188bde1c06c47507fb (patch)
tree488f6d8b8d7858734c3ba53791316cd05bfc4762
parenteed534dcd28b2b85cf5e9c195c68d6d9c80bfb3e (diff)
[feat] print list of keys nicely in the cli
-rwxr-xr-xsrc/leap/bitmask/cli/bitmask_cli.py14
-rw-r--r--src/leap/bitmask/core/mail_services.py4
2 files changed, 15 insertions, 3 deletions
diff --git a/src/leap/bitmask/cli/bitmask_cli.py b/src/leap/bitmask/cli/bitmask_cli.py
index 0c1fe832..e51a41b7 100755
--- a/src/leap/bitmask/cli/bitmask_cli.py
+++ b/src/leap/bitmask/cli/bitmask_cli.py
@@ -194,6 +194,19 @@ def do_print_result(stuff):
print Fore.RED + 'ERROR:' + '%s' % obj['error'] + Fore.RESET
+def do_print_key_list(stuff):
+ obj = json.loads(stuff[0])
+ if obj['error']:
+ do_print_result(stuff)
+ return
+
+ keys = obj['result']
+ print Fore.GREEN
+ for key in keys:
+ print key["fingerprint"] + " " + key['address']
+ print Fore.RESET
+
+
def do_print_key(stuff):
obj = json.loads(stuff[0])
if obj['error']:
@@ -334,6 +347,7 @@ def send_command(cli):
if subargs.list:
data += ['list']
+ cb = do_print_key_list
elif subargs.export:
data += ['export']
diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py
index 8e64f997..0dd53189 100644
--- a/src/leap/bitmask/core/mail_services.py
+++ b/src/leap/bitmask/core/mail_services.py
@@ -349,9 +349,7 @@ class KeymanagerService(HookableService):
def do_list_keys(self, userid):
km = self._container.get_instance(userid)
d = km.get_all_keys()
- d.addCallback(
- lambda keys: [
- (key.address, key.fingerprint) for key in keys])
+ d.addCallback(lambda keys: [dict(key) for key in keys])
return d
def do_export(self, userid, address):