feat: Integrates playbook client into hpa-executable.
This commit is contained in:
@@ -4,6 +4,7 @@ import ConfigurationClient
|
||||
import Dependencies
|
||||
import Foundation
|
||||
import Logging
|
||||
import PlaybookClient
|
||||
|
||||
struct CreateCommand: AsyncParsableCommand {
|
||||
|
||||
@@ -57,40 +58,16 @@ struct CreateCommand: AsyncParsableCommand {
|
||||
var extraOptions: [String] = []
|
||||
|
||||
mutating func run() async throws {
|
||||
try await _run()
|
||||
}
|
||||
|
||||
private func _run() async throws {
|
||||
@Dependency(\.coders) var coders
|
||||
@Dependency(\.cliClient) var cliClient
|
||||
@Dependency(\.configurationClient) var configurationClient
|
||||
|
||||
let loggingOptions = globals.loggingOptions(commandName: Self.commandName)
|
||||
|
||||
try await cliClient.withLogger(loggingOptions) {
|
||||
@Dependency(\.logger) var logger
|
||||
|
||||
let json = try await cliClient.generateJSON(
|
||||
generateJsonOptions,
|
||||
logging: loggingOptions
|
||||
)
|
||||
|
||||
logger.debug("JSON string: \(json)")
|
||||
|
||||
let arguments = [
|
||||
"--tags", "setup-project",
|
||||
"--extra-vars", "project_dir=\(self.projectDir)",
|
||||
"--extra-vars", "'\(json)'"
|
||||
] + extraOptions
|
||||
|
||||
try await cliClient.runPlaybookCommand(
|
||||
globals.playbookOptions(
|
||||
arguments: arguments,
|
||||
configuration: nil
|
||||
),
|
||||
logging: loggingOptions
|
||||
)
|
||||
}
|
||||
@Dependency(\.playbookClient) var playbookClient
|
||||
try await playbookClient.run.createProject(.init(
|
||||
projectDirectory: projectDir,
|
||||
shared: globals.sharedPlaybookRunOptions(
|
||||
commandName: Self.commandName,
|
||||
extraOptions: extraOptions
|
||||
),
|
||||
template: .init(directory: templateDir),
|
||||
useLocalTemplateDirectory: localTemplateDir
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user