Files
swift-hpa/Sources/hpa/BuildCommand.swift

56 lines
1.3 KiB
Swift

import ArgumentParser
import CliClient
import Dependencies
struct BuildCommand: AsyncParsableCommand {
static let commandName = "build"
static let configuration = CommandConfiguration.playbook(
commandName: commandName,
abstract: "Build a home performance assesment project.",
examples: (label: "Build Project", example: "\(commandName) /path/to/project")
)
@OptionGroup var globals: GlobalOptions
@Argument(
help: "Path to the project directory.",
completion: .directory
)
var projectDir: String
@Argument(
help: "Extra arguments passed to the playbook."
)
var extraArgs: [String] = []
mutating func run() async throws {
try await _run()
// try await runPlaybook(
// commandName: Self.commandName,
// globals: globals,
// extraArgs: extraArgs,
// "--tags", "build-project",
// "--extra-vars", "project_dir=\(projectDir)"
// )
}
private func _run() async throws {
try await withSetupLogger(commandName: Self.commandName, globals: globals) {
@Dependency(\.cliClient) var cliClient
try await cliClient.runPlaybookCommand(
globals.playbookOptions(
arguments: [
"--tags", "build-project",
"--extra-vars", "project_dir=\(self.projectDir)"
],
configuration: nil
)
)
}
}
}