feat: Removes cli-client

This commit is contained in:
2024-12-16 17:14:25 -05:00
parent 8c402f3f5f
commit 85b285347b
32 changed files with 837 additions and 1580 deletions

View File

@@ -1,6 +1,6 @@
import ArgumentParser
import CliClient
import CliDoc
import CommandClient
import ConfigurationClient
import Dependencies
@@ -16,14 +16,14 @@ struct GenerateConfigurationCommand: AsyncParsableCommand {
Note {
"""
If a directory is not supplied then a configuration file will be created
at \("'~/.config/hpa-playbook/config'".yellow).
at \("'~/.config/hpa/config.toml'".yellow).
"""
}
VStack {
"EXAMPLE:".yellow.bold
"Create a directory and generate the configuration".green
ShellCommand("mkdir -p ~/.config/hpa-playbook")
ShellCommand("hpa generate-config --path ~/.config/hpa-playbook")
ShellCommand("mkdir -p ~/.config/hpa")
ShellCommand("hpa generate-config --path ~/.config/hpa")
}
}
.separator(.newLine(count: 2))
@@ -39,7 +39,7 @@ struct GenerateConfigurationCommand: AsyncParsableCommand {
@Flag(
name: .shortAndLong,
help: "Generate a json file, instead of default env style"
help: "Generate a json file, instead of the default toml style"
)
var json: Bool = false
@@ -56,26 +56,18 @@ struct GenerateConfigurationCommand: AsyncParsableCommand {
}
private func _run() async throws {
@Dependency(\.cliClient) var cliClient
@Dependency(\.configurationClient) var configurationClient
try await cliClient.withLogger(globals.loggingOptions(commandName: Self.commandName)) {
try await globals.loggingOptions(commandName: Self.commandName).withLogger {
@Dependency(\.logger) var logger
let actualPath: File
let output = try await configurationClient.generate(.init(
force: force,
json: json,
path: path != nil ? .directory(path!) : nil
))
if let path, let file = File("\(path)/config.\(json ? "json" : "toml")") {
actualPath = file
} else {
actualPath = .default
}
logger.debug("Generating config at path: \(actualPath.path)")
try await configurationClient.generate(
at: actualPath,
force: force
)
print(output)
}
}
}