class EcoRake module Lib module People # The top level task that organizes all the people sync class SyncRely < EcoRake::Lib::People::BaseTask FORWARD_RULES = { enviro: :mirror, schema: :mirror, folder: :mirror, only_stats: :mirror, no_policy: :mirror, no_get: :mirror, no_email: :mirror, simulate: :mirror }.freeze option_forwarding(**FORWARD_RULES) attr_const :target_task def task(*_args) sh_continue rake_sync_command end private def rake_sync_command rake_command( namespaced_task, *forward_options(*FORWARD_RULES.keys - [:enviro]) ) end def rake_command(task_name, *options) string_cmd(base_command(task_name), '--', *options) end def base_command(task_name = namespaced_task) string_cmd('rake', task_name) end def namespaced_task(task_name = target_task) ns = self.class.namespace || '' ns_with_enviro = ns.split(':').any? {|s| s == options[:enviro]} ns = "#{ns}:#{options[:enviro]}" unless ns_with_enviro "#{ns}:#{task_name || self.class.task}" end end end end end