41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/kindle_util/cli.rb', line 41
def execute
Logging.logger.root.appenders = Logging.appenders.stdout
Logging.logger.root.level = debug? ? :debug : :info
self.username ||= ask("Enter amazon username: ")
self.password ||= ask("Enter amazon password: ") { |q| q.echo = false }
crawler = AmazonCrawler.new(username, password, cache?)
items = crawler.owned_items
filter_list.each do |name, pattern|
items = items.select {|item| item[name] =~ pattern }
end
case action
when "list"
items.each do |item|
puts debug? ? item.pretty_inspect : format_item(item)
end
when "reset_lpr"
items.each do |item|
logger.info "Resetting last page read for: #{format_item(item)}"
crawler.reset_lpr(item)
end
else
logger.error "Unknown action: #{action}"
end
end
|