27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/musicapp/cli.rb', line 27
def set
new_metadata = $stdin.read.each_line.map {|l| JSON.parse(l) }
properties = new_metadata.flat_map(&:keys).uniq.sort
current_metadata = Script.get_metadata(properties | %w(name))
current_metadata.zip(new_metadata).each do |(current_value, new_value)|
puts current_value["name"]
new_value.each do |k, v|
puts " #{k}:"
puts " #{current_value[k]}"
puts " -> #{v}"
end
end
print "Update?: "
exit 1 unless $stdin.gets.chomp =~ /^y(es)?/i
Script.set_metadata(new_metadata)
puts "Complete!"
rescue ::Musicapp::Error => e
color_warn e.message
exit 1
rescue ::JSON::ParserError => e
color_warn e.message
exit 2
end
|