Class: I18nContextGenerator::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/i18n_context_generator/cli.rb

Overview

Thor-based CLI entry point for the i18n-context-generator command.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/i18n_context_generator/cli.rb', line 37

def self.exit_on_failure?
  true
end

.extraction_optionsObject



27
28
29
30
31
32
33
34
35
# File 'lib/i18n_context_generator/cli.rb', line 27

def self.extraction_options
  Config::Schema.cli_definitions.each do |definition|
    option definition.cli_name, **definition.thor_options
  end
  option :translations, type: :string, hide: true,
                        desc: 'Deprecated: comma-separated translation files'
  option :keys, type: :string, hide: true,
                desc: 'Deprecated: comma-separated key filters'
end

Instance Method Details

#applyObject



87
88
89
# File 'lib/i18n_context_generator/cli.rb', line 87

def apply
  run_workflow('apply')
end

#checkObject



68
69
70
# File 'lib/i18n_context_generator/cli.rb', line 68

def check
  run_workflow('check')
end

#extractObject



62
63
64
# File 'lib/i18n_context_generator/cli.rb', line 62

def extract
  run_workflow(nil)
end

#initObject



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/i18n_context_generator/cli.rb', line 94

def init
  config_path = '.i18n-context-generator.yml'

  if File.exist?(config_path) && !options[:force]
    say_error 'Config file already exists. Use --force to overwrite.'
    exit 1
  end

  File.write(config_path, sample_config)
  say "Created #{config_path}"
end

#planObject



74
75
76
# File 'lib/i18n_context_generator/cli.rb', line 74

def plan
  run_workflow('plan')
end

#preview_diffObject



81
82
83
# File 'lib/i18n_context_generator/cli.rb', line 81

def preview_diff
  run_workflow('preview_diff')
end

#versionObject



107
108
109
# File 'lib/i18n_context_generator/cli.rb', line 107

def version
  say "i18n-context-generator #{VERSION}"
end