#!/usr/bin/env ruby require 'optparse' require_relative '../lib/dropbox_utility' DropboxUtility::authenticate options = {} help = nil OptionParser.new do |o| o.banner = "Usage: #{o.program_name} [options]" o.on('-i','--info','Displays user information') { |o| options[:user_info] = o } o.on('-u FILENAME','--upload FILENAME','Specifies filename to upload') { |o| options[:filename] = o } o.on('-l [PATH]','--list [PATH]', 'Lists contents of PATH specified.', 'Uses root directory if PATH not given.') { |o| options[:folder] = o ? o : '/' } help = o.to_s if ARGV.length == 0 then puts help; exit end begin o.parse! rescue Exception => e puts e.message abort help end end if options[:user_info] then DropboxUtility::client.get_info end if options[:filename] then DropboxUtility::Files::upload(options[:filename]) end if options[:folder] then DropboxUtility::Files::list(options[:folder]) end