Sha256: edb512284d543c9398f9e7180f2880d35819531555eaa3589915a5b8adddf31c

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require 'optparse'
require File.dirname(__FILE__) + '/rdoc_readme'

class Logger
  def format_message(severity, timestamp, progname, msg)
    "#{msg}\n"
  end
end

module TwitterArchive
  class Runner
    def self.runner
      @ta = TwitterArchive::Base.new

      parse_options 

      unless File.exists? @ta.config_file
        puts "Not config file found at '#{@ta.config_file}'"
        puts "See 'twitter_archive --help' for more details"
        exit
      end

      @ta.load_config

      puts @ta.get_latest
      @ta.save_config
    end

    def self.parse_options
      OptionParser.new do |opts|
        opts.summary_width = 25

        opts.on('-v', '--version') do 
          puts "twitter_archive (#{TwitterArchive::VERSION})\n\n"
          exit
        end
        opts.on('-h', '--help') do
          #RDoc::usage() #exits app 
          RDocReadme.rdoc_usage('usage', 'options')
          exit
        end
        opts.on('-V', '--verbose') do
          puts "Verbose!"
        end
        opts.on('-I', '--install') do
          puts "Installing example .twitter_archive.yml to your home directory"
          require "ftools"
          if File.exists? ENV['HOME'] + '/.twitter_archive.yml'
            puts " - #{ENV['HOME']}/.twitter_archive.yml already exists, skipping"
          else
            File.copy( File.dirname(__FILE__) + '/../../config/example.yml', ENV['HOME'] + '/.twitter_archive.yml')
          end
          exit
        end
        opts.on('-cFILE', '--config FILE') do |file|
          @ta.config_file = file
          puts "Config file: #{file}"
          exit
        end

      end.parse!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csexton-twitter_archive-0.0.5 lib/twitter_archive/runner.rb