mirror of
https://github.com/nishiki/manage-password.git
synced 2025-03-19 21:04:35 +00:00
fix bug import preview
This commit is contained in:
parent
c412aae362
commit
906a7d4b4b
2 changed files with 5 additions and 5 deletions
5
Cli.rb
5
Cli.rb
|
@ -186,10 +186,9 @@ class Cli
|
|||
|
||||
if not force
|
||||
if result.is_a?(Array) && !result.empty?
|
||||
i = 0
|
||||
result.each do |r|
|
||||
puts "# --------------------"
|
||||
puts "# Id: #{i}"
|
||||
puts "# Id: #{r[MPW::ID]}"
|
||||
puts "# Name: #{r[MPW::NAME]}"
|
||||
puts "# Group: #{r[MPW::GROUP]}"
|
||||
puts "# Server: #{r[MPW::SERVER]}"
|
||||
|
@ -198,8 +197,6 @@ class Cli
|
|||
puts "# Password: #{r[MPW::PASSWORD]}"
|
||||
puts "# Port: #{r[MPW::PORT]}"
|
||||
puts "# Comment: #{r[MPW::COMMENT]}"
|
||||
|
||||
i += 1
|
||||
end
|
||||
|
||||
confirm = ask("Are you sure to import this file: #{file} ? (y/N) ")
|
||||
|
|
5
MPW.rb
5
MPW.rb
|
@ -336,6 +336,7 @@ class MPW
|
|||
def importPreview(file)
|
||||
begin
|
||||
result = Array.new()
|
||||
id = 0
|
||||
|
||||
data = IO.read(file)
|
||||
data.lines do |line|
|
||||
|
@ -343,8 +344,10 @@ class MPW
|
|||
@error_msg = "Can't import, the file is bad format!"
|
||||
return false
|
||||
else
|
||||
result.push(line.parse_csv)
|
||||
result.push(line.parse_csv.unshift(id))
|
||||
end
|
||||
|
||||
id += 1
|
||||
end
|
||||
|
||||
return result
|
||||
|
|
Loading…
Add table
Reference in a new issue