Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use highline for cli prompts

  • Loading branch information...
commit d331d3c705c7635f8ca26cda730b310f9bd33582 1 parent 737da02
Matt Petty authored August 29, 2012
10  bin/kindle
@@ -4,13 +4,13 @@ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4 4
 $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5 5
 
6 6
 require 'kindle'
7  
- 
  7
+require 'highline/import'
  8
+
  9
+
8 10
 unless login = ARGV[0]
9  
-  print "Enter your Amazon login:"
10  
-  login = gets
  11
+  login = ask("Enter your username:  ") { |q| q.echo = true }
11 12
 end
12  
-print "Enter your password for Amazon (We don't store this)"
13  
-passwd = gets
  13
+passwd = ask("Enter your password (This is not stored):  ") { |q| q.echo = "*" }
14 14
 
15 15
 begin
16 16
   k = Kindle::Kindle.new(:login => login, :password => passwd)
1  kindle.gemspec
@@ -19,5 +19,6 @@ Gem::Specification.new do |s|
19 19
   s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20 20
   s.require_paths = ["lib"]
21 21
   s.add_dependency "nokogiri"
  22
+  s.add_dependency "highline"
22 23
   s.add_dependency "mechanize"
23 24
 end
4  lib/kindle.rb
@@ -31,7 +31,7 @@ def initialize(options = {:login => nil, :password => nil})
31 31
     end
32 32
 
33 33
     def first_page
34  
-      @agent.get(KINDLE_URL)
  34
+      @current_page = @agent.get(KINDLE_URL)
35 35
     end
36 36
 
37 37
     def login(page=first_page)
@@ -39,7 +39,7 @@ def login(page=first_page)
39 39
       lp.forms.first.email = @login
40 40
       lp.forms.first.password = @password
41 41
       @current_page = lp.forms.first.submit
42  
-      @current_page
  42
+      @current_page.forms.first.submit
43 43
     end
44 44
 
45 45
     def fetch_highlights

0 notes on commit d331d3c

Please sign in to comment.
Something went wrong with that request. Please try again.