diff --git a/Cli.rb b/Cli.rb index 403c7dd..3f14b13 100644 --- a/Cli.rb +++ b/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) ") diff --git a/MPW.rb b/MPW.rb index e1d3492..96e5f0c 100644 --- a/MPW.rb +++ b/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