feat: Integrates playbook client into hpa-executable.

This commit is contained in:
2024-12-16 10:29:58 -05:00
parent 35d9422f07
commit da810d0a45
10 changed files with 151 additions and 146 deletions

View File

@@ -2,6 +2,7 @@ import ArgumentParser
import CliClient
import Dependencies
import Foundation
import PlaybookClient
struct BuildCommand: AsyncParsableCommand {
@@ -34,33 +35,14 @@ struct BuildCommand: AsyncParsableCommand {
var extraOptions: [String] = []
mutating func run() async throws {
try await _run()
}
@Dependency(\.playbookClient) var playbookClient
private func _run() async throws {
@Dependency(\.cliClient) var cliClient
let projectDir: String
if projectDirectory == nil {
guard let pwd = ProcessInfo.processInfo.environment["PWD"] else {
throw ProjectDirectoryNotSupplied()
}
projectDir = pwd
} else {
projectDir = projectDirectory!
}
try await cliClient.runPlaybookCommand(
globals.playbookOptions(
arguments: [
"--tags", "build-project",
"--extra-vars", "project_dir=\(projectDir)"
],
configuration: nil
),
logging: globals.loggingOptions(commandName: Self.commandName)
)
try await playbookClient.run.buildProject(.init(
projectDirectory: projectDirectory,
shared: globals.sharedPlaybookRunOptions(
commandName: Self.commandName,
extraOptions: extraOptions
)
))
}
}
struct ProjectDirectoryNotSupplied: Error {}