5
6
7
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
|
# File 'lib/scarlet/runner.rb', line 5
def self.go!(argv)
options = { :format => :html }
OptionParser.new do |opts|
opts.banner = <<-EOF
Usage:
scarlet [options] file
scarlet --generate destination
EOF
argv = ["-h"] if argv.empty?
opts.on "-f", "--format FORMAT", "Format to generate" do |format|
options[:format] = format.to_sym
end
opts.on "-t", "--template FILE", "ERB template file to use" do |file|
options[:template] = file
end
opts.on "-g", "--generate DEST", "Generate javascript and stylesheet files" do |path|
Scarlet::Generator.files(path)
exit
end
opts.on "-h", "--help", "Show this message" do
puts opts
exit
end
begin
opts.parse!(argv)
rescue OptionParser::InvalidOption => e
STDERR.puts e.message, "\n", opts
exit(-1)
end
end
file = File.read(argv[0])
slideshow = Scarlet::Slideshow.new(file, options)
puts slideshow.render
end
|