#!/usr/bin/env ruby require "thor" require "irb" require_relative "../lib/localer" module Localer class CLI < Thor desc "version", "Print Localer version" def version say Localer::VERSION end desc "check [/path/to/rails/application]", "Check missing translations" def check(app_path = Localer::Config::APP_PATH) Localer.configure(options.dup.merge(app_path: app_path)) connect_to_rails if Localer.data.complete? say "\xE2\x9C\x94 No missing translations found.", :green else missing_translations = Localer.data.missing_translations say "\xE2\x9C\x96 Missing translations found (#{missing_translations.count}):", :red missing_translations.each do |tr| say "* #{tr}" end exit 1 end end default_task :check private def connect_to_rails return if Localer::Rails.connect! say "No Rails application found" exit 1 end end end Localer::CLI.start(ARGV)