Index: etherws/trunk/etherws.py
===================================================================
--- etherws/trunk/etherws.py	(revision 198)
+++ etherws/trunk/etherws.py	(revision 199)
@@ -9,5 +9,4 @@
 #   - websocket-client-0.7.0
 #   - tornado-2.3
-#   - PyYAML-3.10
 #
 # ===========================================================================
@@ -44,5 +43,4 @@
 import time
 import json
-import yaml
 import fcntl
 import base64
@@ -559,10 +557,15 @@
                 if entry:
                     mac = EthernetFrame.format_mac(mac)
-                    list_.append([vid, mac, entry.port.number, int(entry.age)])
-        return {'result': list_}
+                    list_.append({
+                        'vid':  vid,
+                        'mac':  mac,
+                        'port': entry.port.number,
+                        'age':  int(entry.age),
+                    })
+        return {'entries': list_}
 
     def handle_listPort(self, params):
         list_ = [self._portstat(p) for p in self._switch.portlist]
-        return {'result': list_}
+        return {'entries': list_}
 
     def handle_addPort(self, params):
@@ -576,5 +579,5 @@
             portnum = interface.open()
             list_.append(self._portstat(self._switch.get_port(portnum)))
-        return {'result': list_}
+        return {'entries': list_}
 
     def handle_delPort(self, params):
@@ -584,5 +587,5 @@
             list_.append(self._portstat(port))
             port.interface.close()
-        return {'result': list_}
+        return {'entries': list_}
 
     def handle_shutPort(self, params):
@@ -592,5 +595,5 @@
             port.shut = bool(p['shut'])
             list_.append(self._portstat(port))
-        return {'result': list_}
+        return {'entries': list_}
 
     def _optparse_tap(self, opt):
@@ -764,4 +767,22 @@
         return json.loads(urllib2.urlopen(req, data).read())
 
+    def maxlen(dict_, key, min_):
+        max_ = max(len(str(r[key])) for r in dict_)
+        return min_ if max_ < min_ else max_
+
+    def print_portlist(result):
+        pmax = maxlen(result, 'port', 4)
+        ymax = maxlen(result, 'type', 4)
+        smax = maxlen(result, 'shut', 5)
+        rmax = maxlen(result, 'rx', 2)
+        tmax = maxlen(result, 'tx', 2)
+        fmt = '  %%%ds  %%%ds  %%%ds  %%%ds  %%%ds  %%s' % \
+              (pmax, ymax, smax, rmax, tmax)
+        print(fmt % ('Port', 'Type', 'State', 'RX', 'TX', 'Target'))
+        for r in result:
+            shut = 'shut' if r['shut'] else 'up'
+            print(fmt %
+                  (r['port'], r['type'], shut, r['rx'], r['tx'], r['target']))
+
     def handle_ctl_addport(args):
         params = [{
@@ -775,5 +796,9 @@
             }
         }]
-        return request(args, 'addPort', params)
+        result = request(args, 'addPort', params)
+        if result['error']:
+            print(result['error']['message'])
+        else:
+            print_portlist(result['result']['entries'])
 
     def handle_ctl_shutport(args):
@@ -781,5 +806,9 @@
             raise ValueError('invalid port: %d' % args.port)
         params = [{'port': args.port, 'shut': args.no}]
-        return request(args, 'shutPort', params)
+        result = request(args, 'shutPort', params)
+        if result['error']:
+            print(result['error']['message'])
+        else:
+            print_portlist(result['result']['entries'])
 
     def handle_ctl_delport(args):
@@ -787,18 +816,33 @@
             raise ValueError('invalid port: %d' % args.port)
         params = [{'port': args.port}]
-        return request(args, 'delPort', params)
+        result = request(args, 'delPort', params)
+        if result['error']:
+            print(result['error']['message'])
+        else:
+            print_portlist(result['result']['entries'])
 
     def handle_ctl_listport(args):
-        return request(args, 'listPort', [])
+        result = request(args, 'listPort', [])
+        if result['error']:
+            print(result['error']['message'])
+        else:
+            print_portlist(result['result']['entries'])
 
     def handle_ctl_listfdb(args):
-        return request(args, 'listFdb', [])
-
-    res = locals()['handle_ctl_' + args.control_method](args)
-
-    if res['error']:
-        print(res['error']['message'])
-    else:
-        print(yaml.safe_dump(res['result']).strip())
+        result = request(args, 'listFdb', [])
+        if result['error']:
+            print(result['error']['message'])
+            return
+        result = result['result']['entries']
+        vmax = maxlen(result, 'vid', 4)
+        mmax = maxlen(result, 'mac', 3)
+        pmax = maxlen(result, 'port', 4)
+        amax = maxlen(result, 'age', 3)
+        fmt = '  %%%ds  %%%ds  %%%ds  %%%ds' % (vmax, mmax, pmax, amax)
+        print(fmt % ('VLAN', 'MAC', 'Port', 'Age'))
+        for r in result:
+            print(fmt % (r['vid'], r['mac'], r['port'], r['age']))
+
+    locals()['handle_ctl_' + args.control_method](args)
 
 
