Sha256: bfa92c5d28c9fd1368c2dce5f050025ef902dddf480ba8c5ea13ebe4a341950a
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
#!/usr/bin/env ruby # coding: utf-8 # prevent i18n gem warning require 'i18n' i18n_gem_config = I18n.config if i18n_gem_config.respond_to?(:enforce_available_locales=) && i18n_gem_config.enforce_available_locales.nil? i18n_gem_config.enforce_available_locales = true end require 'i18n/tasks' require 'i18n/tasks/commands' require 'slop' err = proc { |message, exit_code| if STDERR.isatty STDERR.puts Term::ANSIColor.yellow('i18n-tasks: ' + message) else STDERR.puts message end exit exit_code } begin ran = false commander = ::I18n::Tasks::Commands slop_adapter = ::I18n::Tasks::SlopCommand args = ARGV.dup args = ['--help'] if args.empty? Slop.parse(args, help: true) do on('-v', '--version', 'Print the version') { puts I18n::Tasks::VERSION exit } commander.cmds.each do |name, attr| slop_dsl = slop_adapter.slop_command(name, attr) { |name, opts, args| begin ran = true commander.run_command name, slop_adapter.parse_slop_opts_args(opts, args) rescue Errno::EPIPE # ignore Errno::EPIPE which is throw when pipe breaks, e.g.: # i18n-tasks missing | head exit 1 end } instance_exec &slop_dsl end end rescue Slop::Error => e err.call(e.message, 64) end err.call("Command unknown: #{args[0]}", 64) if !ran && args[0]
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
i18n-tasks-0.7.1 | bin/i18n-tasks |
i18n-tasks-0.7.0 | bin/i18n-tasks |