+
+usage = ->
+ console.log "usage: #{process.argv[0]} #{process.argv[1]} command [args...]"
+ console.log "valid commands are:"
+ for k, v of af
+ console.log "\t#{k}" unless k is 'login'
+
+# parse and act on commandline arguments unless we were require()d as a module
+if require.main is module
+ args = process.argv[2..]
+ if args.length is 0
+ usage()
+ else if not af[args[0]]
+ console.log "unknown command \"#{args[0]}\""
+ usage()
+ else
+ session = new Session()
+ session.api args[0], args[1..], (err, result) ->
+ if err?
+ console.log "error: ", err
+ if result?
+ console.log "result: ", result