#!/usr/bin/env ruby # frozen_string_literal: true require 'feedlrop' require "simpleoptparse" require 'yaml' token, user_id, hash = Feedlrop::Cli.setup banner = "Usage: bundle exec feedlrop --cmd=(lp|lpd|r)" opts = {} Simpleoptparse::Simpleoptparse.parse(ARGV, opts, banner, Arxutils_Sqlite3::VERSION, nil) do |parser| parser.on("--cmd X", %w[lp lpd r]) { |x| opts["cmd"] = x } end flop = Feedlrop::Feedlrop.new( token, hash ) cmd = opts["cmd"] # way = :REMOTE # way = :LOCAL # way = :LOCAL_PSTORE # way = :LOCAL_PSTORE_AND_DB # way = :REMOTE ERROR_CODE_INVALID_CMD = 100 case cmd when "lp" # :LOCAL_PSTORE # puts "way=#{way}" # exit flop.check_backup # exit when "lpd" # :LOCAL_PSTORE_AND_DB # puts "way=#{way}" # exit # flop.check_backup flop.csv_to_db # exit when "r" # :REMOTE puts "cmd=#{cmd}" # exit flop.csv_open(hash['output_dir']) ret = flop.all_unread_count puts "all_unread_count=#{ret.size}" flop.csv_close else puts "cmd=#{cmd}" exit ERROR_CODE_INVALID_CMD end