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
47
48
49
50
51
|
# File 'lib/cheepub/cli.rb', line 21
def execute
params = {}
if config
params = YAML.safe_load(config).symbolize_keys!
end
params[:author] = author
params[:title] = title
params[:output] = output
params[:titlepage] = titlepage?
params[:debug] = debug?
params[:pageDirection] = page_direction
if json?
params[:template] = nil
print Cheepub::Markdown.parse(src, params).to_json
exit 0
end
if latex?
gen = Cheepub::Generator::Latex.new(src, params)
else
gen = Cheepub::Generator::Epub.new(src, params)
end
begin
gen.execute
rescue Cheepub::Error => e
puts "Error: #{e.message}"
if params[:debug]
puts e.backtrace
end
exit(1)
end
end
|