namespace :itrp_export_monitor do GENERATE_HELP = %(Generate a ruby file to configure and start the ITRP Export Monitor:\n itrp-export-monitor generate[,,]) desc GENERATE_HELP task :generate, [:export_id, :email_address, :imap_password] do |t, args| check_required_args(args, [:export_id, :email_address, :imap_password], GENERATE_HELP) monitor_name = "export_monitor.#{args.export_id}" File.open("#{Dir.pwd}/#{monitor_name}.rb", 'w'){ |f| f.write(<']) #task :list, [:api_token] do |t, args| # check_required_args(args, [:api_token]) # $stdout.puts "Searching for scheduled exports..." # Itrp::Client.new(api_token: args.api_token).each('/exports') # $stdout.puts "Account #{args.name} created successfully. The login instructions for #{account.url} are mailed to #{args.primary_email}." #end # Helper methods # test if required arguments are provided def check_required_args(args, fields, help) missing = fields.select{|field| args.send(field) == nil || args.send(field) == '' } unless missing.empty? $stderr.puts "\n#{help}" $stderr.puts "\nMissing required arguments: #{missing.join(', ')}" exit(1) end end end