@@ -56,9 +56,10 @@ public struct OptionFormatter: Sendable {
56
56
public let prefix : @Sendable ( ) -> String
57
57
public let body : @Sendable ( _ key: String ) -> String
58
58
public let separator : @Sendable ( ) -> String
59
+ public let value : @Sendable ( _ value: String ) -> String
59
60
60
61
public func format( key: String , value: String ) -> String {
61
- prefix ( ) + body( key) + separator( ) + value
62
+ prefix ( ) + body( key) + separator( ) + self . value ( value )
62
63
}
63
64
64
65
func format( encoding: OptionEncoding ) -> String {
@@ -71,14 +72,17 @@ public struct OptionFormatter: Sendable {
71
72
/// - prefix: Closure that returns the prefix string
72
73
/// - body: Closure that transforms the key string for formatting
73
74
/// - separator: Closure that returns the string that separates the key and value
75
+ /// - value: Closure that transforms the value string for formatting
74
76
public init (
75
77
prefix: @escaping @Sendable ( ) -> String ,
76
78
body: @escaping @Sendable ( _ key: String ) -> String ,
77
- separator: @escaping @Sendable ( ) -> String
79
+ separator: @escaping @Sendable ( ) -> String ,
80
+ value: @escaping @Sendable ( _ value: String ) -> String
78
81
) {
79
82
self . prefix = prefix
80
83
self . body = body
81
84
self . separator = separator
85
+ self . value = value
82
86
}
83
87
84
88
/// Initialize a new formatter
@@ -87,15 +91,18 @@ public struct OptionFormatter: Sendable {
87
91
/// - prefix: Name spaced closure that returns the prefix string for a Flag
88
92
/// - body: Name spaced closure that transforms the key string for formatting
89
93
/// - separator: Name spaced closure that returns the string that separates the key and value
94
+ /// - value: Name spaced closure that transforms the value string for formatting
90
95
public init (
91
96
prefix: PrefixFormatter = . empty,
92
97
body: BodyFormatter = . empty,
93
- separator: SeparatorFormatter = . space
98
+ separator: SeparatorFormatter = . space,
99
+ value: BodyFormatter = . empty
94
100
) {
95
101
self . init (
96
102
prefix: prefix. transform,
97
103
body: body. transform,
98
- separator: separator. transform
104
+ separator: separator. transform,
105
+ value: value. transform
99
106
)
100
107
}
101
108
}
@@ -126,6 +133,7 @@ public struct BodyFormatter: Sendable {
126
133
public static let empty = Self { $0 }
127
134
public static let kebabCase = Self ( CaseConverter . kebabCase)
128
135
public static let snakeCase = Self ( CaseConverter . snakeCase)
136
+ public static let singleQuote = Self { " ' \( $0) ' " }
129
137
}
130
138
131
139
/// Name space for a closure that returns the separator string between an Option's key and value
0 commit comments