6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/pix_scale/command.rb', line 6
def self.run(*arguments)
if /\A(-h|--help)\z/ =~ arguments[0]
puts <<-EOM
Usage: pix_scale [-t TYPE] FILE... SCALE|WIDTH_HEIGHT
Example1: pix_scale foo.png 0.5
Example2: pix_scale foo.png 240_180
Example3: pix_scale -t png foo 0.5
EOM
exit(true)
elsif /\A(-v|--version)\z/ =~ arguments[0]
puts PixScale::VERSION
exit(true)
elsif /\A(-t|--type)\z/ =~ arguments[0]
type = arguments[1]
arguments.shift(2)
end
scale = arguments.pop
arguments.each do |pic_path|
Pic.scale_and_save(pic_path, scale, type)
end
end
|