feat: Adds generate commands that call to pandoc to generate pdf, latex, and html files from a project.

This commit is contained in:
2024-12-13 15:33:20 -05:00
parent d1b3379815
commit 3f56dda568
22 changed files with 606 additions and 57 deletions

View File

@@ -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 {}