feat: Integrates playbook client into hpa-executable.
This commit is contained in:
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user