lib/i18n-js/cli/export_command.rb in i18n-js-4.0.0 vs lib/i18n-js/cli/export_command.rb in i18n-js-4.0.1

- old
+ new

@@ -25,10 +25,18 @@ "A Ruby file that must be loaded" ) do |require_file| options[:require_file] = require_file end + opts.on( + "-q", + "--quiet", + "A Ruby file that must be loaded" + ) do |quiet| + options[:quiet] = quiet + end + opts.on("-h", "--help", "Prints this help") do ui.exit_with opts.to_s end end @@ -37,15 +45,15 @@ unless options[:config_file] ui.fail_with("=> ERROR: you need to specify the config file") end - ui.stdout_print("=> Config file:", options[:config_file].inspect) + log("=> Config file:", options[:config_file].inspect) config_file = File.expand_path(options[:config_file]) if options[:require_file] - ui.stdout_print("=> Require file:", options[:require_file].inspect) + log("=> Require file:", options[:require_file].inspect) require_file = File.expand_path(options[:require_file]) end unless File.file?(config_file) ui.fail_with( @@ -64,10 +72,16 @@ time = Benchmark.realtime do load_require_file!(require_file) if require_file I18nJS.call(config_file: config_file) end - ui.stdout_print("=> Done in #{time.round(2)}s") + log("=> Done in #{time.round(2)}s") + end + + private def log(*args) + return if options[:quiet] + + ui.stdout_print(*args) end private def set_defaults! config_file = "./config/i18n.yml" require_file = "./config/environment.rb"