Permalink
Browse files

Use highline for cli prompts

  • Loading branch information...
1 parent 737da02 commit d331d3c705c7635f8ca26cda730b310f9bd33582 @lodestone committed Aug 29, 2012
Showing with 8 additions and 7 deletions.
  1. +5 −5 bin/kindle
  2. +1 −0 kindle.gemspec
  3. +2 −2 lib/kindle.rb
View
@@ -4,13 +4,13 @@ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
require 'kindle'
-
+require 'highline/import'
+
+
unless login = ARGV[0]
- print "Enter your Amazon login:"
- login = gets
+ login = ask("Enter your username: ") { |q| q.echo = true }
end
-print "Enter your password for Amazon (We don't store this)"
-passwd = gets
+passwd = ask("Enter your password (This is not stored): ") { |q| q.echo = "*" }
begin
k = Kindle::Kindle.new(:login => login, :password => passwd)
View
@@ -19,5 +19,6 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.add_dependency "nokogiri"
+ s.add_dependency "highline"
s.add_dependency "mechanize"
end
View
@@ -31,15 +31,15 @@ def initialize(options = {:login => nil, :password => nil})
end
def first_page
- @agent.get(KINDLE_URL)
+ @current_page = @agent.get(KINDLE_URL)
end
def login(page=first_page)
lp = page.link_with(:text => "Sign in").click
lp.forms.first.email = @login
lp.forms.first.password = @password
@current_page = lp.forms.first.submit
- @current_page
+ @current_page.forms.first.submit
end
def fetch_highlights

0 comments on commit d331d3c

Please sign in to comment.