Created
September 11, 2019 20:45
-
-
Save InukVT/8389b4b493a2034112b4dc1ded3b7b91 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // | |
| // main.swift | |
| // PM Changer | |
| // | |
| // Created by Bastian Inuk Christensen on 11/09/2019. | |
| // Copyright © 2019 Inuk Entertainment. All rights reserved. | |
| // | |
| import Foundation | |
| import CSV | |
| struct Bitwarden: Codable { | |
| let folder: String | |
| let favorite: String | |
| let type: String | |
| let name: String | |
| let notes: String | |
| let fields: String | |
| let login_uri: String | |
| let login_username: String | |
| let login_password: String | |
| let login_totp: String | |
| } | |
| struct Dashlane: Codable { | |
| let website: String | |
| let name: String | |
| let login: String | |
| let password: String | |
| let note: String | |
| } | |
| let rawCSV = FileHandle.standardInput.readDataToEndOfFile() | |
| let decoder = CSVDecoder().sync | |
| let bitwarden = try decoder.decode(Bitwarden.self, from: rawCSV) | |
| let dashlane: [Dashlane] = bitwarden.map{ login in | |
| return Dashlane(website: login.login_uri, name: login.name, login: login.login_username, password: login.login_password, note: login.notes) | |
| } | |
| let encoder = CSVEncoder().sync | |
| let document = try encoder.encode(dashlane) | |
| FileHandle.standardOutput.write(document) |
This file contains hidden or 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
| // swift-tools-version:5.1 | |
| // The swift-tools-version declares the minimum version of Swift required to build this package. | |
| import PackageDescription | |
| let package = Package( | |
| name: "pmchanger", | |
| products: [ | |
| // Products define the executables and libraries produced by a package, and make them visible to other packages. | |
| .library( | |
| name: "pmchanger", | |
| targets: ["pmchanger"]), | |
| ], | |
| dependencies: [ | |
| // Dependencies declare other packages that this package depends on. | |
| // .package(url: /* package url */, from: "1.0.0"), | |
| .package(url: "https://github.com/skelpo/CSV", from: "1.0.0") | |
| ], | |
| targets: [ | |
| // Targets are the basic building blocks of a package. A target can define a module or a test suite. | |
| // Targets can depend on other targets in this package, and on products in packages which this package depends on. | |
| .target( | |
| name: "pmchanger", | |
| dependencies: ["CSV"]), | |
| .testTarget( | |
| name: "pmchangerTests", | |
| dependencies: ["pmchanger"]), | |
| ] | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment