18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/cli.rb', line 18
def merge
begin
raise ArgumentError, "Missing template" unless !options[:template].empty?
template = ""
requests,answers = []
merge = Textmerge::Merge.new(options)
template = merge.read_template
if options[:input] && File.exists?(options[:input])
puts "Building from input file"
answers = merge.get_responses_from_input_file
else
requests = merge.get_requests(template)
answers = merge.get_responses(requests)
end
output = merge.merge_responses(answers,template)
if !options[:output].empty?
merge.write_file(output)
else
puts output
end
rescue Exception => e
say e.message, :red
end
end
|