mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 14:12:41 +00:00
wip
This commit is contained in:
37
dots/Sources/ShellClient/Client.swift
Normal file
37
dots/Sources/ShellClient/Client.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
import Dependencies
|
||||
import Foundation
|
||||
import XCTestDynamicOverlay
|
||||
#if canImport(FoundationNetworking)
|
||||
import FoundationNetworking
|
||||
#endif
|
||||
|
||||
public struct ShellClient {
|
||||
public var foregroundShell: ([String]) throws -> Void
|
||||
public var backgroundShell: ([String]) throws -> String
|
||||
|
||||
public func foregroundShell(_ arguments: String...) throws {
|
||||
try self.foregroundShell(arguments)
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func backgroundShell(_ arguments: String...) throws -> String {
|
||||
try self.backgroundShell(arguments)
|
||||
}
|
||||
}
|
||||
|
||||
extension ShellClient: TestDependencyKey {
|
||||
|
||||
public static let noop = Self.init(
|
||||
foregroundShell: unimplemented(),
|
||||
backgroundShell: unimplemented(placeholder: "")
|
||||
)
|
||||
|
||||
public static let testValue: ShellClient = .noop
|
||||
}
|
||||
|
||||
extension DependencyValues {
|
||||
public var shellClient: ShellClient {
|
||||
get { self[ShellClient.self] }
|
||||
set { self[ShellClient.self] = newValue }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user