module Tagger class CLI < Thor desc "generate", "an AnlayticsEvent file" option :platform, required: true option :out, required: true def generate(url) puts "Generate AnalyticsEvent.#{options[:platform] == 'ios' ? 'swift' : 'kotlin'}" # Download as CSV downloader = Tagger::Downloader.new(url) csv = downloader.download() # Parse CSV raw_file = CSV.parse(csv, headers: true) events = raw_file.map { |row| Tagger::Event.new(name: row[1]) }.select { |event| event.valid? } generator = Tagger::Generator.new(events, options[:platform].to_sym) generator.generate(options[:out]) end end end