Sha256: 41b6f3e9709d71ec05d5842c0d2479cf20cc3241faeb151801dcb164c22024f2
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module I18nJSON class CLI class InitCommand < Command command_name "init" description "Initialize a project" parse do |opts| opts.banner = "Usage: i18n-json #{name} [options]" opts.on( "-cCONFIG_FILE", "--config=CONFIG_FILE", "The configuration file that will be generated" ) do |config_file| options[:config_file] = config_file end opts.on("-h", "--help", "Prints this help") do ui.exit_with opts.to_s end end command do file_path = File.expand_path(options[:config_file]) if File.file?(file_path) ui.fail_with("ERROR: #{file_path} already exists!") end FileUtils.mkdir_p(File.dirname(file_path)) File.open(file_path, "w") do |file| file << <<~YAML --- translations: - file: app/javascript/locales.json patterns: - "*" - "!*.activerecord" - "!*.errors" - "!*.number.nth" YAML end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
i18n-json-0.0.3 | lib/i18n-json/cli/init_command.rb |
i18n-json-0.0.2 | lib/i18n-json/cli/init_command.rb |