mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-04-18 05:22:11 +00:00
parent
0f6f7c6503
commit
d2bb2aa2f6
@ -11,13 +11,14 @@ struct SetupView: View {
|
|||||||
index: 1,
|
index: 1,
|
||||||
nestedView: nil,
|
nestedView: nil,
|
||||||
actionText: "Install") {
|
actionText: "Install") {
|
||||||
installLaunchAgent()
|
installLaunchAgent()
|
||||||
}
|
}
|
||||||
SetupStepView(text: "Add this line to your shell config (.bashrc or .zshrc) telling SSH to talk to SecretAgent when it wants to authenticate. Drag this into your config file.",
|
SetupStepView(text: "Add this line to your shell config (.bashrc or .zshrc) telling SSH to talk to SecretAgent when it wants to authenticate. Drag this into your config file.",
|
||||||
index: 2,
|
index: 2,
|
||||||
nestedView: SetupStepCommandView(text: Constants.socketPrompt),
|
nestedView: SetupStepCommandView(instructions: Constants.socketPrompts, selectedShellInstruction: Constants.socketPrompts.first!),
|
||||||
actionText: "Added") {
|
actionText: "Added") {
|
||||||
markAsDone()
|
markAsDone()
|
||||||
|
}
|
||||||
SetupStepView<Spacer>(text: "Secretive will periodically check with GitHub to see if there's a new release. If you see any network requests to GitHub, that's why.",
|
SetupStepView<Spacer>(text: "Secretive will periodically check with GitHub to see if there's a new release. If you see any network requests to GitHub, that's why.",
|
||||||
index: 3,
|
index: 3,
|
||||||
nestedView: nil,
|
nestedView: nil,
|
||||||
@ -78,7 +79,7 @@ struct SetupStepView<NestedViewType: View>: View {
|
|||||||
}) {
|
}) {
|
||||||
Text(actionText)
|
Text(actionText)
|
||||||
}.disabled(completed)
|
}.disabled(completed)
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,33 +87,40 @@ struct SetupStepView<NestedViewType: View>: View {
|
|||||||
|
|
||||||
struct SetupStepCommandView: View {
|
struct SetupStepCommandView: View {
|
||||||
|
|
||||||
let text: String
|
let instructions: [ShellConfigInstruction]
|
||||||
|
|
||||||
|
@State var selectedShellInstruction: ShellConfigInstruction
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading) {
|
TabView(selection: $selectedShellInstruction) {
|
||||||
Text(text)
|
ForEach(instructions) { instruction in
|
||||||
.lineLimit(nil)
|
VStack(alignment: .leading) {
|
||||||
.font(.system(.caption, design: .monospaced))
|
Text(instruction.text)
|
||||||
.multilineTextAlignment(.leading)
|
.lineLimit(nil)
|
||||||
.frame(minHeight: 50)
|
.font(.system(.caption, design: .monospaced))
|
||||||
HStack {
|
.multilineTextAlignment(.leading)
|
||||||
Spacer()
|
.frame(minHeight: 50)
|
||||||
Button(action: copy) {
|
HStack {
|
||||||
Text("Copy")
|
Spacer()
|
||||||
|
Button(action: copy) {
|
||||||
|
Text("Copy")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.tabItem {
|
||||||
|
Text(instruction.shell)
|
||||||
}
|
}
|
||||||
|
.tag(instruction)
|
||||||
|
.padding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding()
|
|
||||||
.background(Color(white: 0, opacity: 0.10))
|
|
||||||
.cornerRadius(10)
|
|
||||||
.onDrag {
|
.onDrag {
|
||||||
NSItemProvider(item: NSData(data: text.data(using: .utf8)!), typeIdentifier: kUTTypeUTF8PlainText as String)
|
return NSItemProvider(item: NSData(data: selectedShellInstruction.text.data(using: .utf8)!), typeIdentifier: kUTTypeUTF8PlainText as String)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func copy() {
|
func copy() {
|
||||||
NSPasteboard.general.declareTypes([.string], owner: nil)
|
NSPasteboard.general.declareTypes([.string], owner: nil)
|
||||||
NSPasteboard.general.setString(text, forType: .string)
|
NSPasteboard.general.setString(selectedShellInstruction.text, forType: .string)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -133,11 +141,26 @@ extension SetupView {
|
|||||||
|
|
||||||
enum Constants {
|
enum Constants {
|
||||||
static let socketPath = (NSHomeDirectory().replacingOccurrences(of: "com.maxgoedjen.Secretive.Host", with: "com.maxgoedjen.Secretive.SecretAgent") as NSString).appendingPathComponent("socket.ssh") as String
|
static let socketPath = (NSHomeDirectory().replacingOccurrences(of: "com.maxgoedjen.Secretive.Host", with: "com.maxgoedjen.Secretive.SecretAgent") as NSString).appendingPathComponent("socket.ssh") as String
|
||||||
static let socketPrompt = "export SSH_AUTH_SOCK=\(socketPath)"
|
static let socketPrompts: [ShellConfigInstruction] = [
|
||||||
|
ShellConfigInstruction(shell: "zsh", text: "export SSH_AUTH_SOCK=\(socketPath)"),
|
||||||
|
ShellConfigInstruction(shell: "bash", text: "export SSH_AUTH_SOCK=\(socketPath)"),
|
||||||
|
ShellConfigInstruction(shell: "fish", text: "set -x SSH_AUTH_SOCK=\(socketPath)"),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ShellConfigInstruction: Identifiable, Hashable {
|
||||||
|
|
||||||
|
var shell: String
|
||||||
|
var text: String
|
||||||
|
|
||||||
|
var id: String {
|
||||||
|
shell
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
||||||
struct SetupView_Previews: PreviewProvider {
|
struct SetupView_Previews: PreviewProvider {
|
||||||
|
Loading…
Reference in New Issue
Block a user