@@ -18,7 +18,7 @@ struct Command: ParsableCommand {
1818 commandName: " webtags " ,
1919 abstract: " Element definitions from web specifications. " ,
2020 discussion: " Generates JSON output describing all elements, attributes and predefined attribute values from the given web browser specifications. " ,
21- version: " 0.1 "
21+ version: " 0.1-unstable "
2222 )
2323
2424 @Option ( name: . customLong( " specs " ) , help: " Short names of the specs to parse and output. " )
@@ -38,6 +38,8 @@ struct Command: ParsableCommand {
3838 LoggingSystem . bootstrap ( StreamLogHandler . standardError)
3939 let logger = Logger ( label: " WebTags " )
4040 . withLogLevel ( logLevel)
41+
42+ let runStartedDate = Date ( )
4143 logger. notice ( " Started run. " , metadata: [ " logLevel " : " \( logLevel) " , " webRefIndex " : " \( webRefIndex) " , " specsToGenerate " : " \( specsToGenerate. joined ( separator: " , " ) ) " ] , source: " \( Self . self) " )
4244
4345 // Parse URL
@@ -62,17 +64,20 @@ struct Command: ParsableCommand {
6264 . filter { specsToGenerate. contains ( $0. shortname) }
6365 . map { try WebRefCrawlResultTransformer ( crawlResult: $0, baseURL: indexURL, parentLogger: logger) }
6466 . map { try $0. transform ( ) }
65- logger. info ( " Specs parsed. " , metadata: [ " specsToGenerate " : " \( specsToGenerate. joined ( separator: " , " ) ) " ] , source: " \( Self . self) " )
67+ logger. info ( " Specs parsed. " , metadata: [ " specsToGenerate " : " \( specsToGenerate. joined ( separator: " , " ) ) " ] , source: " \( Self . self) " )
68+
69+ let webTags = WebTags ( generatedAt: runStartedDate, generatedSpecs: specsToGenerate, specs: parsedSpecs)
6670
6771 // Encode output as JSON
6872 logger. debug ( " Generating JSON... " , source: " \( Self . self) " )
6973 let encoder = JSONEncoder ( )
74+ encoder. dateEncodingStrategy = . iso8601
7075 if prettyPrint {
7176 encoder. outputFormatting = [ . prettyPrinted, . sortedKeys, . withoutEscapingSlashes]
7277 } else {
7378 encoder. outputFormatting = [ . withoutEscapingSlashes]
7479 }
75- let jsonData = try encoder. encode ( parsedSpecs )
80+ let jsonData = try encoder. encode ( webTags )
7681 guard let jsonString = String ( data: jsonData, encoding: . utf8) else {
7782 throw EncodingFailedError ( message: " Failed to convert JSON data to string. " )
7883 }
0 commit comments