1. Sumin Byeon
  2. gdocsdb

Commits

Sumin Byeon  committed d820f7c

Implemented a naive command line interface.

  • Participants
  • Parent commits 7f338e8
  • Branches default

Comments (0)

Files changed (1)

File helloworld.py

View file
     feed = gd_client.GetListFeed(key, wksht_id, query=query)
     return feed
 
+# Here 'key' is the name of each column of the spreadsheet.
+# Column names appear to be case insensitive.
 def insert_row(gd_client, key, wksht_id, row_data):
     entry = gd_client.InsertRow(row_data, key, wksht_id)
     if isinstance(entry, gdata.spreadsheet.SpreadsheetsList):
         print 'Inserted!'
 
+# 'index' is zero-based.
 def update_row(gd_client, key, wksht_id, index, row_data):
     feed = gd_client.GetListFeed(key, wksht_id)
     entry = gd_client.UpdateRow(feed.entry[index], row_data)
 #    for key in entry.custom:
 #       print '%s: %s' % (key, entry.custom[key].text)
 
-# Here 'key' is the name of each column of the spreadsheet. It appears to be
-# case insensitive.
-#insert_row(client, key, 'default', {'key':'value'})
+while True:
+    cmd = raw_input('> ')
+    args = cmd.split()
 
-# 'index' is zero-based.
-#update_row(client, key, 'default', 1, {'key':'new value'})
-
-delete_row(client, key, 'default', 0)
+    if args[0] == 'list':
+        for entry in get_list_feed(client, key, 'default').entry:
+            for key in entry.custom:
+                print entry.custom[key].text
+    elif args[0] == 'insert':
+        insert_row(client, key, 'default', {'key':cmd[len(args[0])+1:]})
+    elif args[0] == 'update':
+        index = int(args[1])
+        update_row(client, key, 'default', index, {'key':cmd[len(args[0])+len(args[1])+2:]})
+    elif args[0] == 'delete':
+        index = int(args[1])
+        delete_row(client, key, 'default', index)