lib/terraforming/cli.rb in terraforming-0.1.6 vs lib/terraforming/cli.rb in terraforming-0.2.0

- old
+ new

@@ -1,8 +1,9 @@ module Terraforming class CLI < Thor class_option :merge, type: :string, desc: "tfstate file to merge" + class_option :overwrite, type: :boolean, desc: "Overwrite existng tfstate" class_option :tfstate, type: :boolean, desc: "Generate tfstate" desc "dbpg", "Database Parameter Group" def dbpg execute(Terraforming::Resource::DBParameterGroup, options) @@ -125,10 +126,18 @@ private def execute(klass, options) result = options[:tfstate] ? tfstate(klass, options[:merge]) : tf(klass) - puts result + + if options[:tfstate] && options[:merge] && options[:overwrite] + open(options[:merge], "w+") do |f| + f.write(result) + f.flush + end + else + puts result + end end def tf(klass) klass.tf end