changeset 27:9e173648d848

stubbing out client CLI
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 12 Dec 2012 18:54:59 -0800
parents 60d7e38a20cd
children 4bed1424bb3f
files wsgraph/client.py
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/wsgraph/client.py	Wed Dec 12 18:42:13 2012 -0800
+++ b/wsgraph/client.py	Wed Dec 12 18:54:59 2012 -0800
@@ -1,12 +1,34 @@
 #!/usr/bin/env python
 
+"""REST API client for WSGraph"""
+
+import json
+import sys
 from model import Graph
 
-class WSGraphClient():
+class WSGraphClient(Graph):
     """REST client for WSGraph"""
 
     def __init__(self, server):
         self.server = server
 
+def main(args=sys.argv[1:]):
+    """CLI interface for REST client for WSGraph"""
+
+    # parse command line options
+    usage = """%prog [options] node [key1=value1] [key2=value2] [...]
+%prog [options] node1 node2 [key1=value1] [key2=value2] [...]"""
+    parser = optparse.OptionParser(usage=usage, description=__doc__)
+    parser.add_option('-H', '--host', '--server', dest='server',
+                      help="WSGraph server URL")
+    options, args = parser.parse_args(args)
+
+    # sanity checks
+    if not options.server:
+        parser.error('-H/--server must be set')
+
+    # instantiate model
+    graph = WSGraphClient(options.server)
+
 if __name__ == '__main__':
     pass # TODO