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 = " This is an application to capture snapshot images of web pages.\n \n Usage: \#{File.basename($0)} [options] [URL]...\n \n Options are:\n BANNER\n opts.separator \"\"\n opts.on(\"-x\", \"--max-width WIDTH\", Integer,\n \"Maximum width (in pixels) of an artifact image.\",\n \"If the page you want to take an snapshot image has \",\n \"width less than the specified value, the original size\",\n \"will be preserved.\",\n \"Default: 960\") { |arg| options[:max_width] = arg }\n opts.on(\"-y\", \"--max-height HEIGHT\", Integer,\n \"Maximum height (in pixels) of an artifact image.\",\n \"If the page you want to take an snapshot image has \",\n \"height less than the specified value, the original size\",\n \"will be preserved.\",\n \"Default: 640\") { |arg| options[:max_height] = arg }\n opts.on(\"-h\", \"--help\",\n \"Show this help message.\") { stdout.puts opts; exit }\n opts.on(\"-v\", \"--version\",\n \"Show the version number of this application.\") { stdout.puts Websnapshot::VERSION; exit }\n opts.parse!(arguments)\n\n if (mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }) || arguments.length == 0\n stdout.puts opts; exit\n end\n end\n\n # do stuff\n arguments.each do |url|\n Websnapshot::take(url, options)\n end\nend\n".gsub(/^ /,'')
|