<commit_before>#! /usr/bin/env ruby
require 'optparse'
require './lib/code_generator/swift_strings_generator'
require './lib/code_generator/objc_header_strings_generator'
require './lib/code_generator/objc_main_strings_generator'
require './lib/key_generator/strings_key_generator'

options = { output: ".", language: "swift" }

parser = OptionParser.new do |opts|
	opts.banner = "Usage: rescodegen [options] input_file"
	opts.separator "Generates some strings"
	opts.separator "Options:"
	opts.on("-l", "--language=swift|objc", "swift or objc") do |l|
		options[:language] = l
	end
	opts.on("-o", "--output=directory", "Directory to create file.") do |o|
		options[:output] = o
	end
end
parser.parse!

abort "Invalid -l argument. Expects swift or objc." if !options[:language].match("swift|objc")
input_file = ARGV.last
abort "Missing input_file.\n\n#{parser.help}" if input_file.nil?
output_file = options[:output] + "/Strings"

def generate_swift_file(code_safe_keys, keys, output_file)
	File.write(output_file + ".swift", SwiftStringsGenerator.new.generate(code_safe_keys, keys))
end

def generate_objc_files(code_safe_keys, keys, output_file)
	File.write(output_file + ".h", ObjcHeaderStringsGenerator.new.generate(code_safe_keys, keys))
	File.write(output_file + ".m", ObjcMainStringsGenerator.new.generate(code_safe_keys, keys))
end

generator = StringsKeyGenerator.new(File.readlines(input_file))
keys = generator.keys
code_safe_keys = generator.code_safe_keys
generate_swift_file(code_safe_keys, keys, output_file) if options[:language] == "swift"
generate_objc_files(code_safe_keys, keys, output_file) if options[:language] == "objc"

<commit_msg>Adds code formatters to rescodegen<commit_after>#! /usr/bin/env ruby
require 'optparse'
require_relative 'code_generator/swift_strings_generator'
require_relative 'code_generator/objc_header_strings_generator'
require_relative 'code_generator/objc_main_strings_generator'
require_relative 'key_generator/strings_key_generator'
require_relative 'code_formatter/swift_code_formatter'
require_relative 'code_formatter/objc_code_formatter'

options = { output: ".", language: "swift" }

parser = OptionParser.new do |opts|
	opts.banner = "Usage: rescodegen [options] input_file"
	opts.separator "Generates some strings"
	opts.separator "Options:"
	opts.on("-l", "--language=swift|objc", "swift or objc") do |l|
		options[:language] = l
	end
	opts.on("-o", "--output=directory", "Directory to create file.") do |o|
		options[:output] = o
	end
end
parser.parse!

abort "Invalid -l argument. Expects swift or objc." if !options[:language].match("swift|objc")
input_file = ARGV.last
abort "Missing input_file.\n\n#{parser.help}" if input_file.nil?
output_file = options[:output] + "/Strings"

def generate_swift_file(code_safe_keys, keys, output_file)
	formatter = SwiftCodeFormatter.new
	code_safe_keys = code_safe_keys.map { |k| formatter.format_string(k) }
	File.write(output_file + ".swift", SwiftStringsGenerator.new.generate(code_safe_keys, keys))
end

def generate_objc_files(code_safe_keys, keys, output_file)
	formatter = ObjcCodeFormatter.new
	code_safe_keys = code_safe_keys.map { |k| formatter.format_string(k) }
	File.write(output_file + ".h", ObjcHeaderStringsGenerator.new.generate(code_safe_keys, keys))
	File.write(output_file + ".m", ObjcMainStringsGenerator.new.generate(code_safe_keys, keys))
end

generator = StringsKeyGenerator.new(File.readlines(input_file))
keys = generator.keys
code_safe_keys = generator.code_safe_keys
generate_swift_file(code_safe_keys, keys, output_file) if options[:language] == "swift"
generate_objc_files(code_safe_keys, keys, output_file) if options[:language] == "objc"


{'fraction_non_alphanumeric': 0.1269408880414056, 'fraction_numerical': 0.0, 'mean_word_length': 6.96529284164859, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1630443', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1215, 'n_words': 250}