8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/websnapshot/cli.rb', line 8
def self.execute(stdout, arguments=[])
options = {
:max_width => 960,
:max_height => 640,
}
mandatory_options = %w( )
parser = OptionParser.new do |opts|
opts.banner = <<-BANNER.gsub(/^ /,'')
This is an application to capture snapshot images of web pages.
Usage: #{File.basename($0)} [options] [URL]...
Options are:
BANNER
opts.separator ""
opts.on("-x", "--max-width WIDTH", Integer,
"Maximum width (in pixels) of an artifact image.",
"If the page you want to take an snapshot image has ",
"width less than the specified value, the original size",
"will be preserved.",
"Default: 960") { |arg| options[:max_width] = arg }
opts.on("-y", "--max-height HEIGHT", Integer,
"Maximum height (in pixels) of an artifact image.",
"If the page you want to take an snapshot image has ",
"height less than the specified value, the original size",
"will be preserved.",
"Default: 640") { |arg| options[:max_height] = arg }
opts.on("-h", "--help",
"Show this help message.") { stdout.puts opts; exit }
opts.on("-v", "--version",
"Show the version number of this application.") { stdout.puts Websnapshot::VERSION; exit }
opts.parse!(arguments)
if (mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }) || arguments.length == 0
stdout.puts opts; exit
end
end
arguments.each do |url|
Websnapshot::take(url, options)
end
end
|