feat: Fixes not creating default config directory
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import ArgumentParser
|
||||
import CliClient
|
||||
import Dependencies
|
||||
|
||||
struct GenerateProjectTemplateCommand: AsyncParsableCommand {
|
||||
|
||||
@@ -36,23 +38,25 @@ struct GenerateProjectTemplateCommand: AsyncParsableCommand {
|
||||
)
|
||||
var extraArgs: [String] = []
|
||||
|
||||
// FIX:
|
||||
mutating func run() async throws {
|
||||
let varsDir = templateVars != nil
|
||||
? ["--extra-vars", "repo_vars_dir=\(templateVars!)"]
|
||||
: []
|
||||
@Dependency(\.cliClient) var cliClient
|
||||
|
||||
let vault = noVault ? ["--extra-vars", "use_vault=false"] : []
|
||||
var arguments = [
|
||||
"--tags", "repo-template",
|
||||
"--extra-vars", "output_dir=\(path)"
|
||||
]
|
||||
|
||||
// try await runPlaybook(
|
||||
// commandName: Self.commandName,
|
||||
// globals: globals,
|
||||
// extraArgs: extraArgs,
|
||||
// [
|
||||
// "--tags", "repo-template",
|
||||
// "--extra-vars", "output_dir=\(path)"
|
||||
// ] + varsDir
|
||||
// + vault
|
||||
// )
|
||||
if let varsDir = templateVars {
|
||||
arguments.append(contentsOf: ["--extra-vars", "repo_vars_dir=\(varsDir)"])
|
||||
}
|
||||
|
||||
if noVault {
|
||||
arguments.append(contentsOf: ["--extra-vars", "use_vault=false"])
|
||||
}
|
||||
|
||||
try await cliClient.runPlaybookCommand(
|
||||
globals.playbookOptions(arguments: arguments, configuration: nil),
|
||||
logging: globals.loggingOptions(commandName: Self.commandName)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import ArgumentParser
|
||||
import CliClient
|
||||
import CliDoc
|
||||
import ConfigurationClient
|
||||
import Dependencies
|
||||
|
||||
struct GenerateConfigurationCommand: AsyncParsableCommand {
|
||||
@@ -42,32 +43,39 @@ struct GenerateConfigurationCommand: AsyncParsableCommand {
|
||||
)
|
||||
var json: Bool = false
|
||||
|
||||
@Flag(
|
||||
name: .shortAndLong,
|
||||
help: "Force generation, overwriting a file if it exists."
|
||||
)
|
||||
var force: Bool = false
|
||||
|
||||
@OptionGroup var globals: BasicGlobalOptions
|
||||
|
||||
mutating func run() async throws {
|
||||
try await _run()
|
||||
}
|
||||
|
||||
// FIX:
|
||||
private func _run() async throws {
|
||||
@Dependency(\.cliClient) var cliClient
|
||||
@Dependency(\.configurationClient) var configurationClient
|
||||
|
||||
try await cliClient.withLogger(globals.loggingOptions(commandName: Self.commandName)) {
|
||||
let actualPath: String
|
||||
@Dependency(\.logger) var logger
|
||||
|
||||
// if let path {
|
||||
// actualPath = "\(path)/config"
|
||||
// } else {
|
||||
// let path = "~/.config/hpa-playbook/"
|
||||
// try await cliClient.runCommand(
|
||||
// quiet: false,
|
||||
// shell: globals.shellOrDefault,
|
||||
// "mkdir", "-p", path
|
||||
// )
|
||||
// actualPath = "\(path)/config"
|
||||
// }
|
||||
let actualPath: File
|
||||
|
||||
fatalError()
|
||||
// try cliClient.createConfiguration(actualPath, json)
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user