1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-20 01:50:04 +00:00

export items with id

This commit is contained in:
Adrien Waksberg 2017-03-03 22:00:15 +01:00
parent 8fb83bd391
commit de4beba3db

View file

@ -517,23 +517,20 @@ class Cli
file = 'export-mpw.yml' if file.to_s.empty?
items = @mpw.list(options)
data = {}
i = 1
items.each do |item|
data.merge!(i => { 'host' => item.host,
'user' => item.user,
'group' => item.group,
'password' => @mpw.get_password(item.id),
'protocol' => item.protocol,
'port' => item.port,
'otp_key' => @mpw.get_otp_key(item.id),
'comment' => item.comment,
'last_edit' => item.last_edit,
'created' => item.created,
}
data.merge!(item.id => { 'host' => item.host,
'user' => item.user,
'group' => item.group,
'password' => @mpw.get_password(item.id),
'protocol' => item.protocol,
'port' => item.port,
'otp_key' => @mpw.get_otp_key(item.id),
'comment' => item.comment,
'last_edit' => item.last_edit,
'created' => item.created,
}
)
i += 1
end
File.open(file, 'w') {|f| f << data.to_yaml}
@ -550,7 +547,6 @@ class Cli
raise I18n.t('form.import.file_not_exist') if not File.exist?(file)
YAML::load_file(file).each_value do |row|
item = Item.new(group: row['group'],
host: row['host'],
protocol: row['protocol'],