Sha256: 7c736f2013ce59f81dd85ae74b05b717bc5ab955cf28ee6e780bc18f6c40b3a6

Contents?: true

Size: 1.91 KB

Versions: 8

Compression:

Stored size: 1.91 KB

Contents

#!/usr/bin/env ruby

require_relative '../lib/i18n/migrations/migrator'
require_relative '../lib/i18n/migrations/config'
require_relative '../lib/i18n/migrations/version'

migrator = I18n::Migrations::Migrator.new

def extract_option(name)
  !!ARGV.delete(name)
end

case ARGV.shift
when 'setup'
  puts 'Where should we create a default config file? [.]'
  dir = gets.chomp
  dir = dir == '' ? '.' : dir
  file = I18n::Migrations::Config.copy_default_config_file(dir)

  puts 'You will need to configure this file before you can get going.'
  puts File.expand_path(file)

when 'new'
  name = ARGV.shift
  if name
    migrator.new_migration name
  else
    STDERR.puts 'Usage: im new [name]'
    exit 1
  end

when 'migrate'
  migrator.migrate(ARGV[0] || 'all')

when 'rollback'
  migrator.rollback(ARGV[0] || 'all')

when 'redo'
  migrator.rollback(ARGV[0] || 'all')
  migrator.migrate(ARGV[0] || 'all')

when 'pull'
  migrator.pull(ARGV[0] || 'all')

when 'push'
  force = extract_option('-f')
  migrator.push(ARGV[0] || 'all', force)

when 'validate'
  migrator.validate(ARGV[0] || 'all')

when 'new_locale'
  locale = ARGV.shift
  if locale
    migrator.new_locale(locale)
  else
    STDERR.puts 'Usage: im new_locale [name]'
    exit 1
  end

when 'version'
  migrator.version

else
  puts <<-USAGE
Usage: i18n-migrate [command]

Commands:
  setup - Setup a new project w/ i18n-migrations.
  new - Create a new migration.
  migrate - Migrate to current version.
  rollback - Rollback to previous version.
  redo - Rollback and then migrate again.
  pull - Pull latest translation spreadsheet. 
  push - Push to translation spreadsheet. (-f to force, without doing a pull first)
  validate - check all translations according to our rules and fix what we can
  new_locale - Copy your current main locale file to a new language, translating all keys.
  version - Print version of locales.

i18n-migrations version #{I18n::Migrations::VERSION}
  USAGE
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
i18n-migrations-2.0.2 bin/i18n-migrate
i18n-migrations-2.0.1 bin/i18n-migrate
i18n-migrations-2.0.0 bin/i18n-migrate
i18n-migrations-1.2.4 bin/i18n-migrate
i18n-migrations-1.2.3 bin/i18n-migrate
i18n-migrations-1.2.2 bin/i18n-migrate
i18n-migrations-1.2.1 bin/i18n-migrate
i18n-migrations-1.2.0 bin/i18n-migrate