Sha256: 36f97d2b3eaf9789c837d19041f667b8e3df7fa2904b6f73fe31a59286d3af8d

Contents?: true

Size: 1.81 KB

Versions: 10

Compression:

Stored size: 1.81 KB

Contents

#!/bin/env ruby

begin
  load 'lib/rrimm.rb'
rescue LoadError
  require 'rrimm'
end

require 'optparse'

options = {
  'action' => :sync,
  'conf_file' => File.join(ENV['HOME'], '.config', 'rrimm', 'rrimm.rb'),
}

OptionParser.new do |opts|
  opts.banner = "Usage: rrimm "
  opts.on('-c', '--config [file]',
          'configuration file used by rrimm') do |conf_file|
    options['conf_file'] = conf_file
  end

  opts.on('-C', '--concurrency N',
          'concurrency level to fetch feeds. Default 1') do |c|
    options['concurrency'] = c.to_i
  end

  opts.on('-q', '--quiet',
          'Activate quiet mode, will only print errors') do
    options['quiet'] = true
  end

  opts.on('-V', '--verbose',
          'Verbose mode') do
    options['verbose'] = true
  end

  opts.on('--category CATEGORY',
          'Run action only on one category"') do |cat|
    options['category'] = cat
  end

  opts.on('-a', '--action [action]', [:sync, :show, :status, :reset],
          'Specify what to do: "sync" feeds, "show" config, display feed "status, reset feed cache"') do |action|
    options['action'] = action
  end

  opts.on_tail("-h", "--help", "You know what it does") do
    puts opts
    exit
  end
end.parse!(ARGV)



conf = RRImm::Config.new
conf.load(options['conf_file'])

fetcher = RRImm::Fetcher.new(conf, options)
IO.open STDOUT.fileno do |ios|
  case options['action']
  when :sync
    fetcher.fetch
  when :show
    conf.show(ios, options['category'])
  when :status
    one_month = 30 * 86400
    one_month_ago = Time.now.to_i - one_month
    six_months_ago = Time.now.to_i - 6 * one_month

    conf.status(ios, one_month_ago, six_months_ago, false, options['category'])
  when :reset
    time = ARGV.shift.to_i
    puts "Will reset cache files more recent than #{Time.at(time)} to this date."
    conf.reset_caches(time)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rrimm-0.14.10 bin/rrimm
rrimm-0.14.9 bin/rrimm
rrimm-0.14.8 bin/rrimm
rrimm-0.14.7 bin/rrimm
rrimm-0.14.6 bin/rrimm
rrimm-0.14.5 bin/rrimm
rrimm-0.14.4 bin/rrimm
rrimm-0.14.3 bin/rrimm
rrimm-0.14.1 bin/rrimm
rrimm-0.14.0 bin/rrimm