bin/update_onebody in onebody-updateagent-0.4.3 vs bin/update_onebody in onebody-updateagent-0.5.0
- old
+ new
@@ -29,13 +29,10 @@
ONEBODY_USER_KEY = config['user_key']
if c = config['converter']
ONEBODY_USE_CONVERTER = c['name']
end
end
- opts.on("-g", "--groups", "Sync groups.csv rather than people.csv") do |g|
- options[:sync_groups] = true
- end
# doesn't work yet
#opts.on("-d", "--delete", "Delete people and families not found in source file") do |d|
# options[:delete] = true
#end
opts.on("--debug", "Enable extra debugging messages.") do |d|
@@ -56,60 +53,41 @@
puts "See #{File.expand_path(File.dirname(File.dirname(__FILE__)))}/example.yml"
puts
exit
end
-if ARGV[0] # path/to/people.csv or path/to/groups.csv
+if ARGV[0] # path/to/people.csv
$: << 'lib'
require 'onebody-updateagent'
puts "Update Agent running at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}"
- if options[:sync_groups]
- agent = ExternalGroupUpdater.new(ARGV[0])
+ agent = PeopleUpdater.new(ARGV[0], config)
+ if options[:test]
+ require 'pp'
+ pp agent.data[0...options[:test]]
+ else
puts "comparing records..."
- agent.compare
+ agent.compare(options[:force])
if agent.has_work?
if options[:confirm]
- case ask("#{agent.create.length + agent.update.length} record(s) to push. Continue? (Yes, No) ") { |q| q.in = %w(yes no y n) }
+ case ask("#{agent.create_count} record(s) to create and #{agent.update_count} record(s) to update. Continue? (Yes, No, Review) ") { |q| q.in = %w(yes no review y n r) }
+ when 'review', 'r'
+ agent.present
+ unless agent.confirm
+ puts "Canceled by user\n"
+ exit
+ end
when 'no', 'n'
puts "Canceled by user\n"
exit
end
end
+ agent.start_sync
agent.push
+ agent.send_notification
+ agent.finish_sync
puts "Completed at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}\n\n"
else
puts "Nothing to push\n\n"
- end
- else # sync people
- agent = PeopleUpdater.new(ARGV[0], config)
- if options[:test]
- require 'pp'
- pp agent.data[0...options[:test]]
- else
- puts "comparing records..."
- agent.compare(options[:force])
- if agent.has_work?
- if options[:confirm]
- case ask("#{agent.create_count} record(s) to create and #{agent.update_count} record(s) to update. Continue? (Yes, No, Review) ") { |q| q.in = %w(yes no review y n r) }
- when 'review', 'r'
- agent.present
- unless agent.confirm
- puts "Canceled by user\n"
- exit
- end
- when 'no', 'n'
- puts "Canceled by user\n"
- exit
- end
- end
- agent.start_sync
- agent.push
- agent.send_notification
- agent.finish_sync
- puts "Completed at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}\n\n"
- else
- puts "Nothing to push\n\n"
- end
end
end
else
puts opt_parser.help
end