feat: Adds generate-config command.
This commit is contained in:
@@ -40,7 +40,7 @@ extension CommandConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
extension GlobalOptions {
|
||||
extension BasicGlobalOptions {
|
||||
|
||||
var shellOrDefault: ShellCommand.Shell {
|
||||
guard let shell else { return .zsh(useDashC: true) }
|
||||
@@ -48,6 +48,11 @@ extension GlobalOptions {
|
||||
}
|
||||
}
|
||||
|
||||
extension GlobalOptions {
|
||||
|
||||
var shellOrDefault: ShellCommand.Shell { basic.shellOrDefault }
|
||||
}
|
||||
|
||||
func ensureString(
|
||||
globals: GlobalOptions,
|
||||
configuration: Configuration,
|
||||
@@ -65,13 +70,14 @@ func ensureString(
|
||||
|
||||
func withSetupLogger(
|
||||
commandName: String,
|
||||
globals: GlobalOptions,
|
||||
globals: BasicGlobalOptions,
|
||||
quietOnlyPlaybook: Bool = false,
|
||||
dependencies setupDependencies: (inout DependencyValues) -> Void = { _ in },
|
||||
operation: @escaping () async throws -> Void
|
||||
) async rethrows {
|
||||
try await withDependencies {
|
||||
$0.logger = .init(label: "\("hpa".yellow)")
|
||||
if globals.quietOnlyPlaybook || !globals.quiet {
|
||||
if quietOnlyPlaybook || !globals.quiet {
|
||||
switch globals.verbose {
|
||||
case 0:
|
||||
$0.logger.logLevel = .info
|
||||
@@ -89,6 +95,21 @@ func withSetupLogger(
|
||||
}
|
||||
}
|
||||
|
||||
func withSetupLogger(
|
||||
commandName: String,
|
||||
globals: GlobalOptions,
|
||||
dependencies setupDependencies: (inout DependencyValues) -> Void = { _ in },
|
||||
operation: @escaping () async throws -> Void
|
||||
) async rethrows {
|
||||
try await withSetupLogger(
|
||||
commandName: commandName,
|
||||
globals: globals.basic,
|
||||
quietOnlyPlaybook: globals.quietOnlyPlaybook,
|
||||
dependencies: setupDependencies,
|
||||
operation: operation
|
||||
)
|
||||
}
|
||||
|
||||
func runPlaybook(
|
||||
commandName: String,
|
||||
globals: GlobalOptions,
|
||||
@@ -156,7 +177,7 @@ func runPlaybook(
|
||||
}
|
||||
|
||||
try await cliClient.runCommand(
|
||||
quiet: globals.quietOnlyPlaybook ? true : globals.quiet,
|
||||
quiet: globals.quietOnlyPlaybook ? true : globals.basic.quiet,
|
||||
shell: globals.shellOrDefault,
|
||||
playbookArgs + args + extraArgs
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user