Created
July 8, 2015 17:36
-
-
Save rhenning/0b20231a73e0881f4668 to your computer and use it in GitHub Desktop.
Passpack to 1Password CSV converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
# PASSPACK_CSV_FIELDS = %i[ | |
# title | |
# username | |
# password | |
# url | |
# tags | |
# notes | |
# ] | |
# ONEPASSWORD_CSV_FIELDS = %i[ | |
# title | |
# location | |
# username | |
# password | |
# notes | |
# ] | |
passpack = CSV.new($stdin) | |
onepassword = CSV.new($stdout) | |
passpack.each do |title, username, password, url, tags, notes, email| | |
unless ARGV.empty? | |
next unless ARGV.any? { |arg| tags.include?(arg) rescue nil } | |
end | |
# this is hideous but i'm too lazy to rethink it atm. | |
notes_with_email = '' | |
notes_with_email << "email_from_passpack: #{email}\n\n" if email | |
notes_with_email << notes if notes | |
notes_with_email = notes_with_email.empty? ? nil : notes_with_email | |
onepassword << [ title, url, (username || email), password, notes_with_email ] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment