feat: Adds generate-config command.

This commit is contained in:
2024-11-29 20:32:32 -05:00
parent 84b002c997
commit 505f7d8013
8 changed files with 143 additions and 30 deletions

View File

@@ -16,6 +16,7 @@ public struct CliClient: Sendable {
public var encoder: @Sendable () -> JSONEncoder = { .init() }
public var loadConfiguration: @Sendable () throws -> Configuration
public var runCommand: @Sendable ([String], Bool, ShellCommand.Shell) async throws -> Void
public var createConfiguration: @Sendable (String) throws -> Void
public func runCommand(
quiet: Bool,
@@ -41,14 +42,14 @@ extension CliClient: DependencyKey {
encoder: JSONEncoder = .init(),
env: [String: String]
) -> Self {
.init {
@Dependency(\.fileClient) var fileClient
@Dependency(\.logger) var logger
return .init {
decoder
} encoder: {
encoder
} loadConfiguration: {
@Dependency(\.logger) var logger
@Dependency(\.fileClient) var fileClient
let urls = try findConfigurationFiles(env: env)
var env = env
@@ -75,6 +76,8 @@ extension CliClient: DependencyKey {
in: nil,
args
))
} createConfiguration: { path in
try fileClient.write(path, Data(Configuration.fileTemplate.utf8))
}
}