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
|
# File 'lib/squatch.rb', line 8
def run(arguments)
unless arguments.empty? || !arguments[0].include?('-')
optparser = OptionParser.new do|opts|
opts.banner = "Usage: squatch -command [FILE/DIR]"
opts.on('-h', '--help', 'Display this help') do
puts optparser
exit
end
opts.on('-v', '--version', 'Display current gem version') do
puts "Squatch-#{VERSION}"
end
opts.on('-f', '--file FILE', 'Squatch FILE in place') do |file|
prepare(file)
end
opts.on('-F', '--folder DIR', 'Squatch files from DIR in place') do |dir|
prepare(dir)
end
end
begin optparser.parse!(arguments)
rescue OptionParser::ParseError => error
puts "#{error}"
puts optparser
exit
end
else
puts `squatch -h`
end
end
|