import Dependencies import Logging import ShellClient public extension CliClient { @discardableResult func withLogger( _ options: LoggingOptions, operation: @Sendable @escaping () async throws -> T ) async rethrows -> T { try await Self.withLogger(options, operation: operation) } @discardableResult static func withLogger( _ options: LoggingOptions, operation: @Sendable @escaping () async throws -> T ) async rethrows -> T { try await withDependencies { $0.logger = .init(label: "\(Constants.executableName)") $0.logger.logLevel = options.logLevel $0.logger[metadataKey: "command"] = "\(options.commandName.blue)" } operation: { try await operation() } } }