mirror of
https://github.com/nishiki/manage-password.git
synced 2025-03-20 13:24:36 +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 not force
|
||||||
if result.is_a?(Array) && !result.empty?
|
if result.is_a?(Array) && !result.empty?
|
||||||
i = 0
|
|
||||||
result.each do |r|
|
result.each do |r|
|
||||||
puts "# --------------------"
|
puts "# --------------------"
|
||||||
puts "# Id: #{i}"
|
puts "# Id: #{r[MPW::ID]}"
|
||||||
puts "# Name: #{r[MPW::NAME]}"
|
puts "# Name: #{r[MPW::NAME]}"
|
||||||
puts "# Group: #{r[MPW::GROUP]}"
|
puts "# Group: #{r[MPW::GROUP]}"
|
||||||
puts "# Server: #{r[MPW::SERVER]}"
|
puts "# Server: #{r[MPW::SERVER]}"
|
||||||
|
@ -198,8 +197,6 @@ class Cli
|
||||||
puts "# Password: #{r[MPW::PASSWORD]}"
|
puts "# Password: #{r[MPW::PASSWORD]}"
|
||||||
puts "# Port: #{r[MPW::PORT]}"
|
puts "# Port: #{r[MPW::PORT]}"
|
||||||
puts "# Comment: #{r[MPW::COMMENT]}"
|
puts "# Comment: #{r[MPW::COMMENT]}"
|
||||||
|
|
||||||
i += 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
confirm = ask("Are you sure to import this file: #{file} ? (y/N) ")
|
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)
|
def importPreview(file)
|
||||||
begin
|
begin
|
||||||
result = Array.new()
|
result = Array.new()
|
||||||
|
id = 0
|
||||||
|
|
||||||
data = IO.read(file)
|
data = IO.read(file)
|
||||||
data.lines do |line|
|
data.lines do |line|
|
||||||
|
@ -343,8 +344,10 @@ class MPW
|
||||||
@error_msg = "Can't import, the file is bad format!"
|
@error_msg = "Can't import, the file is bad format!"
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
result.push(line.parse_csv)
|
result.push(line.parse_csv.unshift(id))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
id += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Add table
Reference in a new issue