Class: I18n::Processes::CLI
- Inherits:
-
Object
- Object
- I18n::Processes::CLI
show all
- Includes:
- Logging
- Defined in:
- lib/i18n/processes/cli.rb
Defined Under Namespace
Classes: ExecutionError
Constant Summary
Constants included
from Logging
Logging::MUTEX, Logging::PROGRAM_NAME
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Logging
log_error, log_stderr, log_verbose, log_warn, program_name, warn_deprecated
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
15
|
# File 'lib/i18n/processes/cli.rb', line 15
def initialize; end
|
Class Method Details
.start(argv) ⇒ Object
11
12
13
|
# File 'lib/i18n/processes/cli.rb', line 11
def self.start(argv)
new.start(argv)
end
|
Instance Method Details
#commands ⇒ Object
50
51
52
53
54
|
# File 'lib/i18n/processes/cli.rb', line 50
def commands
base_task
@commands ||= ::I18n::Processes::Commands.cmds.transform_keys { |k| k.to_s.tr('_', '-') }
end
|
#context ⇒ Object
46
47
48
|
# File 'lib/i18n/processes/cli.rb', line 46
def context
@context ||= ::I18n::Processes::Commands.new(base_task)
end
|
#run(argv) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/i18n/processes/cli.rb', line 39
def run(argv)
I18n.with_locale(base_task.internal_locale) do
name, *options = parse!(argv.dup)
context.run(name, *options)
end
end
|
#start(argv) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/i18n/processes/cli.rb', line 17
def start(argv)
auto_output_coloring do
begin
exit 1 if run(argv) == :exit_1
rescue OptionParser::ParseError => e
error e.message, 64
rescue I18n::Processes::CommandError => e
begin
error e.message, 78
ensure
log_verbose e.backtrace * "\n"
end
rescue Errno::EPIPE
exit 1
end
end
rescue ExecutionError => e
exit e.exit_code
end
|