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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/rubbr.rb', line 24
def run(args = ARGV)
opts = OptionParser.new do |opts|
opts.version = Rubbr::VERSION
opts.banner = 'Usage: rubbr [options]'
opts.on('-f', '--format [FORMAT]', [:dvi, :ps, :pdf],
'Select output format (dvi, ps, pdf)') do |format|
@@cmd_opts[:format] = format
end
opts.on('-F', '--force', 'Force rebuild (even if files not changed)') do
@@cmd_opts[:force] = true
end
opts.on('-e', '--engine [ENGINE]', [:pdflatex, :ps, :pdf],
'Select processing engine (latex, pdflatex)') do |engine|
@@cmd_opts[:engine] = engine
end
opts.on('-n', '--distribution-name NAME', String, 'Set distribution name') do |name|
@@cmd_opts[:distribution_name] = name
end
opts.on('-d', '--display', 'Display the document') do
@@cmd_opts[:view] = true
end
opts.on('-s', '--spell', 'Spell check source files') do
@@cmd_opts[:spell] = true
end
opts.on('-l', '--loop', 'Go into a build loop') do
@@cmd_opts[:loop] = true
end
opts.on('-D', '--loop-delay [DELAY]', Float, 'Set loop delay in seconds (default: 0.5)') do |delay|
@@cmd_opts[:loop_delay] = delay
end
opts.on('-v', '--verbose', 'Enable verbose feedback') do
@@cmd_opts[:verbose] = true
end
opts.on('-V', '--verboser', 'Enable verbose feedback for hboxes') do
@@cmd_opts[:verbose] = true
@@cmd_opts[:verboser] = true
end
opts.on('-c', '--color', 'Enable colorized feedback') do
@@cmd_opts[:color] = true
end
opts.on('-h', '--help', 'Show this help message') do
puts opts
exit 1
end
end
begin
opts.parse!(args)
rescue OptionParser::ParseError
puts opts
exit 1
end
case
when @@cmd_opts[:spell]
Rubbr::Spell.new.check
when @@cmd_opts[:view]
exit 2 unless Rubbr::Builder.build
Rubbr::Viewer.view
when @@cmd_opts[:loop]
Rubbr::Builder.build_in_a_loop
else
exit 2 unless Rubbr::Builder.build
end
end
|