@@ -101,8 +101,17 @@ let defaultAvailableAttr = "@available(SwiftStdlib 5.7, *)"
101101@main
102102struct VariadicsGenerator : ParsableCommand {
103103 @Option ( help: " The maximum arity of declarations to generate. " )
104- var maxArity : Int
104+ var maxArity : Int = 10
105+
106+ @Flag ( help: " Suppress status messages while generating. " )
107+ var silent : Bool = false
105108
109+ func log( _ message: String , terminator: String = " \n " ) {
110+ if !silent {
111+ print ( message, terminator: terminator, to: & standardError)
112+ }
113+ }
114+
106115 func run( ) throws {
107116 precondition ( maxArity > 1 )
108117 precondition ( maxArity < Counter . bitWidth)
@@ -126,14 +135,12 @@ struct VariadicsGenerator: ParsableCommand {
126135
127136 """ )
128137
129- print ( " Generating concatenation overloads... " , to : & standardError )
138+ log ( " Generating concatenation overloads... " )
130139 for (leftArity, rightArity) in Permutations ( totalArity: maxArity) {
131140 guard rightArity != 0 else {
132141 continue
133142 }
134- print (
135- " Left arity: \( leftArity) Right arity: \( rightArity) " ,
136- to: & standardError)
143+ log ( " Left arity: \( leftArity) Right arity: \( rightArity) " )
137144 emitConcatenation ( leftArity: leftArity, rightArity: rightArity)
138145 }
139146
@@ -143,50 +150,48 @@ struct VariadicsGenerator: ParsableCommand {
143150
144151 output ( " \n \n " )
145152
146- print ( " Generating quantifiers... " , to : & standardError )
153+ log ( " Generating quantifiers... " )
147154 for arity in 0 ... maxArity {
148- print ( " Arity \( arity) : " , terminator: " " , to : & standardError )
155+ log ( " Arity \( arity) : " , terminator: " " )
149156 for kind in QuantifierKind . allCases {
150- print ( " \( kind. rawValue) " , terminator: " " , to : & standardError )
157+ log ( " \( kind. rawValue) " , terminator: " " )
151158 emitQuantifier ( kind: kind, arity: arity)
152159 }
153- print ( " repeating " , terminator: " " , to : & standardError )
160+ log ( " repeating " , terminator: " " )
154161 emitRepeating ( arity: arity)
155- print ( to : & standardError )
162+ log ( " " )
156163 }
157164
158- print ( " Generating atomic groups... " , to : & standardError )
165+ log ( " Generating atomic groups... " )
159166 for arity in 0 ... maxArity {
160- print ( " Arity \( arity) : " , terminator: " " , to : & standardError )
167+ log ( " Arity \( arity) : " , terminator: " " )
161168 emitAtomicGroup ( arity: arity)
162- print ( to : & standardError )
169+ log ( " " )
163170 }
164171
165- print ( " Generating alternation overloads... " , to : & standardError )
172+ log ( " Generating alternation overloads... " )
166173 for (leftArity, rightArity) in Permutations ( totalArity: maxArity) {
167- print (
168- " Left arity: \( leftArity) Right arity: \( rightArity) " ,
169- to: & standardError)
174+ log ( " Left arity: \( leftArity) Right arity: \( rightArity) " )
170175 emitAlternation ( leftArity: leftArity, rightArity: rightArity)
171176 }
172177
173- print ( " Generating 'AlternationBuilder.buildBlock(_:)' overloads... " , to : & standardError )
178+ log ( " Generating 'AlternationBuilder.buildBlock(_:)' overloads... " )
174179 for arity in 1 ... maxArity {
175- print ( " Capture arity: \( arity) " , to : & standardError )
180+ log ( " Capture arity: \( arity) " )
176181 emitUnaryAlternationBuildBlock ( arity: arity)
177182 }
178183
179- print ( " Generating 'capture' and 'tryCapture' overloads... " , to : & standardError )
184+ log ( " Generating 'capture' and 'tryCapture' overloads... " )
180185 for arity in 0 ... maxArity {
181- print ( " Capture arity: \( arity) " , to : & standardError )
186+ log ( " Capture arity: \( arity) " )
182187 emitCapture ( arity: arity)
183188 }
184189
185190 output ( " \n \n " )
186191
187192 output ( " // END AUTO-GENERATED CONTENT \n " )
188193
189- print ( " Done! " , to : & standardError )
194+ log ( " Done! " )
190195 }
191196
192197 func tupleType( arity: Int , genericParameters: ( ) -> String ) -> String {
0 commit comments