feat: Adds generate commands that call to pandoc to generate pdf, latex, and html files from a project.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import ArgumentParser
|
||||
import CliClient
|
||||
import Dependencies
|
||||
import Foundation
|
||||
|
||||
struct BuildCommand: AsyncParsableCommand {
|
||||
|
||||
@@ -9,16 +10,23 @@ struct BuildCommand: AsyncParsableCommand {
|
||||
static let configuration = CommandConfiguration.playbook(
|
||||
commandName: commandName,
|
||||
abstract: "Build a home performance assesment project.",
|
||||
examples: (label: "Build Project", example: "\(commandName) /path/to/project")
|
||||
examples: (
|
||||
label: "Build project when in the project directory.",
|
||||
example: "\(commandName)"
|
||||
),
|
||||
(
|
||||
label: "Build project from outside the project directory.",
|
||||
example: "\(commandName) --project-directory /path/to/project"
|
||||
)
|
||||
)
|
||||
|
||||
@OptionGroup var globals: GlobalOptions
|
||||
|
||||
@Argument(
|
||||
@Option(
|
||||
help: "Path to the project directory.",
|
||||
completion: .directory
|
||||
)
|
||||
var projectDir: String
|
||||
var projectDirectory: String?
|
||||
|
||||
@Argument(
|
||||
help: "Extra arguments / options passed to the playbook."
|
||||
@@ -27,19 +35,21 @@ struct BuildCommand: AsyncParsableCommand {
|
||||
|
||||
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 {
|
||||
@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: [
|
||||
@@ -52,3 +62,5 @@ struct BuildCommand: AsyncParsableCommand {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
struct ProjectDirectoryNotSupplied: Error {}
|
||||
|
||||
Reference in New Issue
Block a user