Introduce KeyImporter protocol to reduce code duplications in SSH key importers
This commit is contained in:
parent
6aa39db657
commit
94a5f8c501
14 changed files with 189 additions and 144 deletions
36
pass/Controllers/KeyImporter.swift
Normal file
36
pass/Controllers/KeyImporter.swift
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// KeyImporter.swift
|
||||
// pass
|
||||
//
|
||||
// Created by Danny Moesch on 15.02.20.
|
||||
// Copyright © 2020 Bob Sun. All rights reserved.
|
||||
//
|
||||
|
||||
import passKit
|
||||
|
||||
protocol KeyImporter {
|
||||
|
||||
static var keySource: KeySource { get }
|
||||
|
||||
static var label: String { get }
|
||||
|
||||
static var menuLabel: String { get }
|
||||
|
||||
func isReadyToUse() -> Bool
|
||||
|
||||
func importKeys() throws
|
||||
}
|
||||
|
||||
extension KeyImporter {
|
||||
|
||||
static var isCurrentKeySource: Bool {
|
||||
return Defaults.gitSSHKeySource == Self.keySource
|
||||
}
|
||||
|
||||
static var menuLabel: String {
|
||||
if isCurrentKeySource {
|
||||
return "✓ \(Self.label)"
|
||||
}
|
||||
return Self.label
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue