feat: Removes cli-client
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import ArgumentParser
|
||||
import CliClient
|
||||
import Dependencies
|
||||
import PandocClient
|
||||
|
||||
// TODO: Need to add a step to build prior to generating file.
|
||||
struct GenerateHtmlCommand: AsyncParsableCommand {
|
||||
@@ -13,12 +13,12 @@ struct GenerateHtmlCommand: AsyncParsableCommand {
|
||||
@OptionGroup var globals: GenerateOptions
|
||||
|
||||
mutating func run() async throws {
|
||||
@Dependency(\.cliClient) var cliClient
|
||||
@Dependency(\.pandocClient) var pandocClient
|
||||
|
||||
try await cliClient.runPandocCommand(
|
||||
globals.pandocOptions(.html),
|
||||
logging: globals.loggingOptions(commandName: Self.commandName)
|
||||
let output = try await pandocClient.run.generateHtml(
|
||||
globals.pandocRunOptions(commandName: Self.commandName)
|
||||
)
|
||||
print(output)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import ArgumentParser
|
||||
import CliClient
|
||||
import Dependencies
|
||||
|
||||
// TODO: Need to add a step to build prior to generating file.
|
||||
@@ -13,11 +12,11 @@ struct GenerateLatexCommand: AsyncParsableCommand {
|
||||
@OptionGroup var globals: GenerateOptions
|
||||
|
||||
mutating func run() async throws {
|
||||
@Dependency(\.cliClient) var cliClient
|
||||
@Dependency(\.pandocClient) var pandocClient
|
||||
|
||||
try await cliClient.runPandocCommand(
|
||||
globals.pandocOptions(.latex),
|
||||
logging: globals.loggingOptions(commandName: Self.commandName)
|
||||
let output = try await pandocClient.run.generateLatex(
|
||||
globals.pandocRunOptions(commandName: Self.commandName)
|
||||
)
|
||||
print(output)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
import ArgumentParser
|
||||
import CliClient
|
||||
import CommandClient
|
||||
import PandocClient
|
||||
|
||||
@dynamicMemberLookup
|
||||
struct GenerateOptions: ParsableArguments {
|
||||
|
||||
@OptionGroup var basic: BasicGlobalOptions
|
||||
|
||||
@Option(
|
||||
name: .shortAndLong,
|
||||
help: "Custom build directory path.",
|
||||
completion: .directory
|
||||
)
|
||||
var buildDirectory: String?
|
||||
|
||||
@Option(
|
||||
name: [.short, .customLong("file")],
|
||||
help: "Files used to generate the output, can be specified multiple times.",
|
||||
@@ -65,20 +73,20 @@ struct GenerateOptions: ParsableArguments {
|
||||
|
||||
extension GenerateOptions {
|
||||
|
||||
func loggingOptions(commandName: String) -> CliClient.LoggingOptions {
|
||||
func loggingOptions(commandName: String) -> LoggingOptions {
|
||||
basic.loggingOptions(commandName: commandName)
|
||||
}
|
||||
|
||||
func pandocOptions(
|
||||
_ fileType: CliClient.PandocOptions.FileType
|
||||
) -> CliClient.PandocOptions {
|
||||
func pandocRunOptions(commandName: String) -> PandocClient.RunOptions {
|
||||
.init(
|
||||
buildDirectory: buildDirectory,
|
||||
extraOptions: extraOptions.count > 0 ? extraOptions : nil,
|
||||
files: files.count > 0 ? files : nil,
|
||||
loggingOptions: .init(commandName: commandName, logLevel: .init(globals: basic, quietOnlyPlaybook: false)),
|
||||
includeInHeader: includeInHeader.count > 0 ? includeInHeader : nil,
|
||||
outputDirectory: outputDirectory,
|
||||
outputFileName: outputFileName,
|
||||
outputFileType: fileType,
|
||||
projectDirectory: projectDirectory,
|
||||
outputFileName: outputFileName,
|
||||
quiet: basic.quiet,
|
||||
shell: basic.shell,
|
||||
shouldBuild: !noBuild
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import ArgumentParser
|
||||
import CliClient
|
||||
import Dependencies
|
||||
import PandocClient
|
||||
|
||||
// TODO: Need to add a step to build prior to generating file.
|
||||
|
||||
@@ -20,11 +20,11 @@ struct GeneratePdfCommand: AsyncParsableCommand {
|
||||
@OptionGroup var globals: GenerateOptions
|
||||
|
||||
mutating func run() async throws {
|
||||
@Dependency(\.cliClient) var cliClient
|
||||
@Dependency(\.pandocClient) var pandocClient
|
||||
|
||||
let output = try await cliClient.runPandocCommand(
|
||||
globals.pandocOptions(.pdf(engine: pdfEngine)),
|
||||
logging: globals.loggingOptions(commandName: Self.commandName)
|
||||
let output = try await pandocClient.run.generatePdf(
|
||||
globals.pandocRunOptions(commandName: Self.commandName),
|
||||
pdfEngine: pdfEngine
|
||||
)
|
||||
|
||||
print(output)
|
||||
|
||||
Reference in New Issue
Block a user