Class: I18nFlow::CLI::CopyCommand
Instance Method Summary
collapse
Methods inherited from CommandBase
#color_enabled?, #exit_with_message, #initialize
Instance Method Details
#dst_file ⇒ Object
29
30
31
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 29
def dst_file
args[1]
end
|
#first_key_node ⇒ Object
37
38
39
40
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 37
def first_key_node
return @first_key_node if defined?(@first_key_node)
@first_key_node = I18nFlow::YamlAstProxy.first_key_node_of(parser.root_proxy)
end
|
#invoke! ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 9
def invoke!
unless src_file && dst_file
exit_with_message(1, 'usage: i18n_flow copy [--locale=LOCALE] SRC_FILE DST_FILE')
end
parser.parse!
I18nFlow::YamlAstProxy.mark_as_todo(parser.root_proxy)
if locale && first_key_node
first_key_node.value = locale
end
File.write(dst_file, parser.root_proxy.to_yaml)
end
|
#locale ⇒ Object
33
34
35
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 33
def locale
options['locale']
end
|
#src_file ⇒ Object
25
26
27
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 25
def src_file
args[0]
end
|