#!/usr/bin/env ruby
#
#  tw2td.rb - 過去のツイートを取得し、tDiary にポストするスクリプト
#
#   (c) 2012, Norihisa Washitake http://washitake.com/diary/public/
#

require 'optparse'

def parse_args(argv, defaults)
  args = defaults
  parser = OptionParser.new(
           "#{$0}: post past daily tweets to tDiary.\n" +
           "Usage: #{$0} [options]", 16
  )
  begin
    parser.on("-d", "--debug", "enter debug mode") { |v|
      args[:debug]   = true
    }
    parser.on("-v", "--verbose","enter verbose mode") { |v|
      args[:verbose] = true
    }
    parser.on("--max-id MAX", Integer,
              "retrieve tweets with smaller id than MAX") { |v|
      args[:max_id]  = v
    }
    parser.on("--days D", Integer, "retrieve tweets for D days") { |v|
      args[:days] = v
    }
    parser.on("-n", "--no-tweet", "do not post actually") { |v|
      args[:no_tweet] = true
    }
    parser.on("--cont", "get MAXID from the previous run") { |v|
      args[:cont] = true
    }
    parser.parse!(argv)
  
  rescue
    puts "#{__FILE__}: unrecognizable option #{ARGV[0]}"
    exit 1
  end

  return args
end

