42 lines
959 B
Swift
42 lines
959 B
Swift
import Dependencies
|
|
import ShellClient
|
|
|
|
func runVault(
|
|
commandName: String,
|
|
options: VaultOptions,
|
|
_ args: [String]
|
|
) async throws {
|
|
try await withSetupLogger(commandName: commandName, globals: options.globals) {
|
|
@Dependency(\.cliClient) var cliClient
|
|
@Dependency(\.logger) var logger
|
|
|
|
logger.debug("Begin run vault: \(options)")
|
|
|
|
let configuration = try cliClient.ensuredConfiguration(nil)
|
|
logger.debug("Configuration: \(configuration)")
|
|
|
|
let path: String
|
|
if let file = options.file {
|
|
path = file
|
|
} else {
|
|
path = try cliClient.findVaultFileInCurrentDirectory()
|
|
}
|
|
|
|
logger.debug("Vault path: \(path)")
|
|
|
|
let defaultArgs = configuration.defaultVaultArgs ?? []
|
|
|
|
try await cliClient.runCommand(
|
|
quiet: options.quiet,
|
|
shell: options.shellOrDefault,
|
|
["ansible-vault"]
|
|
+ args
|
|
+ defaultArgs
|
|
+ options.extraArgs
|
|
+ [path]
|
|
)
|
|
|
|
fatalError()
|
|
}
|
|
}
|