lib/rezept/actions.rb in rezept-0.4.0 vs lib/rezept/actions.rb in rezept-0.4.1
- old
+ new
@@ -11,10 +11,11 @@
end
def export(options)
@converter.set_options(options)
@client.set_options(options)
+ Rezept::TermColor.color = options['color']
docs = @client.get_documents
if options['write']
if options['split']
content = ''
@@ -33,35 +34,36 @@
end
def apply(options)
@converter.set_options(options)
@client.set_options(options)
+ Rezept::TermColor.color = options['color']
dry_run = options['dry_run'] ? '[Dry run] ' : ''
local = @converter.dslfile_to_h(options['file'])
remote = @client.get_documents
unless options['prefix'].nil?
prefix = Regexp.new("^#{Regexp.escape(options['prefix'])}")
local.reject!{|d| not d['name'] =~ prefix }
remote.reject!{|d| not d['name'] =~ prefix }
end
- _apply_docs(local, remote, dry_run)
+ _apply_docs(local, remote, dry_run, options)
end
- def _apply_docs(local, remote, dry_run)
+ def _apply_docs(local, remote, dry_run, options)
local.each do |l|
l_ids = l.delete('account_ids')
r_ids = []
r = _choice_by_name(remote, l['name'])
if r.nil?
info("#{dry_run}Create the new document #{l['name'].inspect}")
@client.create_document(l) if dry_run.empty?
else
r_ids = r.delete('account_ids')
- diff = Rezept::Utils.diff(@converter, r, l)
+ diff = Rezept::Utils.diff(@converter, r, l, options['color'])
if diff == "\n"
info("#{dry_run}No changes '#{l['name']}'")
else
warn("#{dry_run}Update the document #{l['name'].inspect}")
@@ -85,10 +87,11 @@
end
end
def convert(options)
@converter.set_options(options)
+ Rezept::TermColor.color = options['color']
fmt = 'unknown'
if not options['format'].nil?
fmt = options['format']
@@ -119,9 +122,10 @@
end
def run_command(options)
dry_run = options['dry_run'] ? '[Dry run] ' : ''
@client.set_options(options)
+ Rezept::TermColor.color = options['color']
if options['instance_ids'].nil? and options['tags'].nil? and (options['inventory'].nil? or options['conditions'].nil?)
raise "Please specify the targets (--instance-ids/-i' or '--target-tags/-t' or '--inventroty/-I and --conditions/-C')"
end