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
|
# File 'lib/cloudit/command/generate.rb', line 13
def index
if @opts.help?
$stdout.puts slop_opts
else
out = @opts[:output]
dir = normalize_directory @opts[:directory]
min = @opts[:minify]
if File.exist? out
if out.eql? DEFAULT_OUT_FILE
i = 1
while File.exist? out
i += 1
out = "out#{i}.json"
end
else
$stdout.puts "cloudit: output file '#{out}' already exists"
return
end
end
json = generate_json dir, min
File.new(out, 'w').write "#{json}\n"
$stdout.puts "Template generated to #{out}"
end
end
|