Class: I18nFlow::CLI::CopyCommand
Instance Method Summary
collapse
Methods inherited from CommandBase
#color_enabled?, #exit_with_message, #initialize
Instance Method Details
#dst_file ⇒ Object
28
29
30
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 28
def dst_file
args[1]
end
|
#first_key_node ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 36
def first_key_node
return @first_key_node if defined?(@first_key_node)
@first_key_node = parser.root_proxy
.send(:indexed_object)
.node
.tap { |n| break unless n.is_a?(Psych::Nodes::Mapping) }
&.tap { |n| break n.children.first }
end
|
#invoke! ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 8
def invoke!
unless src_file && dst_file
exit_with_message(1, 'usage: i18n_flow copy [--locale=LOCALE] SRC_FILE DST_FILE')
end
parser.parse!
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
32
33
34
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 32
def locale
options['locale']
end
|
#src_file ⇒ Object
24
25
26
|
# File 'lib/i18n_flow/cli/copy_command.rb', line 24
def src_file
args[0]
end
|