#!/usr/bin/env ruby

require 'optparse'
require 'bloggerpost'
require 'flickr'
require 'fileutils'

work_dir = nil

config = BloggerPost::Config.new

cache_file = config.work_dir + 'flickr_auth_cache'

flickr = Flickr.new(cache_file, '063adbe28d97be54e9237571c2dabeee', '4dfa7ef8cf14fe57')
if flickr.auth.token
  puts 'Already the token is cached.'
else
  url = flickr.auth.login_link('read')
  puts "You must visit\n#{url}\nto authorize this application. Press enter when you have done so. This is the only time you will have to do this."
  gets
  flickr.auth.getToken
  flickr.auth.cache_token
  FileUtils.chmod(0600, cache_file)
end
