feat: Adds generate commands that call to pandoc to generate pdf, latex, and html files from a project.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import Foundation
|
||||
|
||||
// NOTE: When adding items, then the 'hpa.toml' resource file needs to be updated.
|
||||
|
||||
/// Represents configurable settings for the command line tool.
|
||||
public struct Configuration: Codable, Equatable, Sendable {
|
||||
public let args: [String]?
|
||||
public let useVaultArgs: Bool
|
||||
public let generate: Generate?
|
||||
public let playbook: Playbook?
|
||||
public let template: Template
|
||||
public let vault: Vault
|
||||
@@ -11,12 +14,14 @@ public struct Configuration: Codable, Equatable, Sendable {
|
||||
public init(
|
||||
args: [String]? = nil,
|
||||
useVaultArgs: Bool = true,
|
||||
generate: Generate? = nil,
|
||||
playbook: Playbook? = nil,
|
||||
template: Template = .init(),
|
||||
vault: Vault = .init()
|
||||
) {
|
||||
self.args = args
|
||||
self.useVaultArgs = useVaultArgs
|
||||
self.generate = generate
|
||||
self.playbook = playbook
|
||||
self.template = template
|
||||
self.vault = vault
|
||||
@@ -32,6 +37,40 @@ public struct Configuration: Codable, Equatable, Sendable {
|
||||
)
|
||||
}
|
||||
|
||||
public struct Generate: Codable, Equatable, Sendable {
|
||||
public let buildDirectory: String?
|
||||
public let files: [String]?
|
||||
public let includeInHeader: [String]?
|
||||
public let outputFileName: String?
|
||||
public let pdfEngine: String?
|
||||
|
||||
public init(
|
||||
buildDirectory: String? = nil,
|
||||
files: [String]? = nil,
|
||||
includeInHeader: [String]? = nil,
|
||||
outputFileName: String? = nil,
|
||||
pdfEngine: String? = nil
|
||||
) {
|
||||
self.buildDirectory = buildDirectory
|
||||
self.files = files
|
||||
self.includeInHeader = includeInHeader
|
||||
self.outputFileName = outputFileName
|
||||
self.pdfEngine = pdfEngine
|
||||
}
|
||||
|
||||
public static let `default` = Self.mock
|
||||
|
||||
public static var mock: Self {
|
||||
.init(
|
||||
buildDirectory: ".build",
|
||||
files: ["Report.md", "Definitions.md"],
|
||||
includeInHeader: ["head.tex", "footer.tex"],
|
||||
outputFileName: "Report",
|
||||
pdfEngine: "xelatex"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public struct Playbook: Codable, Equatable, Sendable {
|
||||
|
||||
public let directory: String?
|
||||
|
||||
@@ -1,13 +1,42 @@
|
||||
# NOTE:
|
||||
# Configuration settings for the `hpa` command line tool.
|
||||
#
|
||||
# Delete settings that are not applicable to your use case.
|
||||
# You can delete settings that are not applicable to your use case.
|
||||
|
||||
# Default arguments / options that get passed into `ansible-playbook` commands.
|
||||
# WARNING: Do not put arguments / options that contain spaces in the same string,
|
||||
# they should be separate strings, for example do not do something like
|
||||
# ['--tags debug'], instead use ['--tags', 'debug'].
|
||||
#
|
||||
args = []
|
||||
|
||||
# Set to true if you want to pass the vault args to `ansible-playbook` commands.
|
||||
useVaultArgs = true
|
||||
|
||||
# NOTE:
|
||||
# Configuration for running the generate command(s). This allows custimizations
|
||||
# to the files that get used to generate the final output (generally a pdf).
|
||||
# See `pandoc --help`. Below are the defaults that get used, which only need
|
||||
# adjusted if your template does not follow the default template design or if
|
||||
# you add extra files to your template that need to be included in the final
|
||||
# output. Also be aware that any of the files specified in the `files` or
|
||||
# `includeInHeader` options, need to be inside the `buildDirectory` when generating
|
||||
# the final output file.
|
||||
|
||||
# [generate]
|
||||
# this relative to the project directory.
|
||||
# buildDirectory = '.build'
|
||||
# pdfEngine = 'xelatex'
|
||||
# includeInHeader = [
|
||||
# 'head.tex',
|
||||
# 'footer.tex'
|
||||
# ]
|
||||
# files = [
|
||||
# 'Report.md',
|
||||
# 'Definitions.md'
|
||||
# ]
|
||||
# outputFileName = 'Report'
|
||||
|
||||
# NOTE:
|
||||
# These are more for local development of the ansible playbook and should not be needed
|
||||
# in most cases. Uncomment the lines if you want to customize the playbook and use it
|
||||
# instead of the provided / default playbook.
|
||||
@@ -17,6 +46,7 @@ useVaultArgs = true
|
||||
#inventory = '/path/to/local/inventory.ini'
|
||||
#version = 'main'
|
||||
|
||||
# NOTE:
|
||||
# These are to declare where your template files are either on your local system or
|
||||
# a remote git repository.
|
||||
[template]
|
||||
@@ -31,6 +61,7 @@ url = 'https://git.example.com/consult-template.git'
|
||||
# branch.
|
||||
version = '1.0.0'
|
||||
|
||||
# NOTE:
|
||||
# Holds settings for `ansible-vault` commands.
|
||||
[vault]
|
||||
# Arguments to pass to commands that use `ansible-vault`, such as encrypting or decrypting
|
||||
|
||||
Reference in New Issue
Block a user