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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/erbside.rb', line 23
def self.cli(argv=ARGV)
require 'optparse'
require 'erbside/runner'
options = {:resources=>[]}
usage = OptionParser.new do |use|
use.banner = 'Usage: erbside [OPTIONS] [FILE1 FILE2 ...]'
use.on('-r', '--resource FILE', 'get metadata from file') do |file|
options[:resources] << file
end
use.on('-f', '--force', 'automatically make overwrites') do
options[:force] = true
end
use.on('-s', '--skip', 'automatically skip overwrites') do
options[:skip] = true
end
use.on('-o', '--stdout', 'dump output to stdout instead of saving') do
options[:output] = $stdout
end
use.on('-t', '--trial', 'run in trial mode') do
$TRIAL = true
end
use.on('--debug', 'run in debug mode') do
$DEBUG = true
end
use.on_tail('-h', '--help', 'display this help information') do
puts use
exit
end
end
usage.parse!(argv)
files = argv
runner = Erbside::Runner.new(files, options)
runner.render
end
|