Sha256: 92e97f5f1f4c75b3e37389816c6016ba513082e5d62e11c52fc8b503c9ca94eb

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

#!/usr/bin/env ruby

require "optparse"
require "ramesh"

USAGE = <<-EOS
Usage:
    ramesh [-d save_dir] [-f filename]                 download the latest image
    ramesh [-d save_dir] [-f filename] 0..120          download the image specified minutes before
    ramesh [-d save_dir] [-f filename] 0..120 0..120   download images within a specified range
    ramesh -h, --help                                  show this usage
EOS

save_dir = Dir.pwd
filename = nil

parser = OptionParser.new(USAGE) do |opt|
  opt.on("-d", "--dir=VAL", "Save directory (default: current directory)") { |val| save_dir = val }
  opt.on("-f", "--filename=VAL", "Save file name (default: timestamp index of downloaded image)") { |val| filename = val }
end

argv = parser.parse(ARGV)

client = Ramesh::Client.new(Ramesh::Logger.new(STDOUT))

case argv.length
when 0
  client.download_image(0, save_dir, filename)
when 1
  client.download_image(argv[0].to_i, save_dir, filename)
when 2
  client.download_sequential_images(argv[0].to_i, argv[1].to_i, save_dir)
else
  $stderr.puts USAGE
  exit 1
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ramesh-1.3.0 bin/ramesh