Skip to content

Instantly share code, notes, and snippets.

@rhenning
Created July 8, 2015 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhenning/0b20231a73e0881f4668 to your computer and use it in GitHub Desktop.
Save rhenning/0b20231a73e0881f4668 to your computer and use it in GitHub Desktop.
Passpack to 1Password CSV converter
require 'csv'
# PASSPACK_CSV_FIELDS = %i[
# title
# username
# password
# url
# tags
# notes
# email
# ]
# 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