module Aigu class CLI def initialize(env, argv) @env = env @command = Aigu::PUBLIC_COMMANDS.include?(argv.first) ? argv.shift : nil @argv = argv parse_options end def run Aigu.send(@command, @options) if @command end def parse_options @options = {} OptionParser.new do |opts| opts.banner = 'Usage: aigu [options]' opts.on('--input-directory=', 'The directory in which the Rails YAML localization files are stored.') do |directory| @options[:input_directory] = directory end opts.on('--output-directory=', 'The directory in which the Rails YAML localization files will be generated.') do |directory| @options[:output_directory] = directory end opts.on('--input-file=', 'The JSON file generated by Accent.') do |file| @options[:input_file] = file end opts.on('--output-file=', 'The JSON file that will be generated for Accent.') do |file| @options[:output_file] = file end opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end end.parse! @argv end end end