Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 95979723e6
Fetching contributors…

Cannot retrieve contributors at this time

executable file 49 lines (38 sloc) 1.615 kb
#!/usr/bin/env ruby
#
# CLI interface to adding articles to your instantpaper account
# by Matthew Lee Hinman (http://writequit.org)
require 'ricepaper'
require 'optparse'
opthash = Hash.new
options = OptionParser.new do |opts|
opts.banner = %q|Usage: #{$0} [options] "<url>" ["<url>" "<url>" ...]|
opts.on("-u", "--username [USER]", "Username") { |opt| opthash['username'] = opt }
opts.on("-p", "--password [PASS]", "Password") { |opt| opthash['password'] = opt }
opts.on("-a", "--authenticate", "Only attempt to authenticate to Instapaper") { |opt| opthash['authenticate'] = opt }
opts.on("-t", "--title [TITLE]", "Optional title for instantpaper entry") { |opt| opthash['title'] = opt }
opts.on("-d", "--description [DESC]", "Optional description for the article") { |opt| opthash['desc'] = opt }
end
options.parse!(ARGV)
rp = RicePaper.new(opthash['username'],opthash['password'])
if opthash['authenticate']
print "Authenticating... "
result = rp.authenticate
puts result ? "Successful." : "Failed."
puts "Error: #{rp.error}" unless result
exit(0)
end
if ARGV.size < 1
puts "I need a url to add to InstantPaper"
end
ARGV.each do |url|
if (!opthash['desc'].nil?)
print "Submitting '#{url}' #{opthash['title'].nil? ? "" : "with title '#{opthash['title']}'"}"
print ", description '#{opthash['desc']}' ... "
else
print "Submitting '#{url}' #{opthash['title'].nil? ? "" : "with title '#{opthash['title']}'"} ... "
end
result = rp.add(url,opthash['title'], opthash['desc'])
puts result ? "Successful." : "Failed."
puts "Error: #{rp.error}" unless result
end
Jump to Line
Something went wrong with that request. Please try again.