From 7add980bce18915b7c576203e11e1928f3921f29 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Fri, 19 May 2023 15:11:29 -0600 Subject: [PATCH] feat: support json5 config format I love comments in json, this is going to be awesome --- Package.swift | 2 +- Sources/hyper-focus/configuration_loader.swift | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index a4972d3..ad7f2ee 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "hyper-focus", platforms: [ - .macOS(.v10_15), + .macOS(.v12), ], dependencies: [ .package(url: "https://github.com/envoy/Ambassador", from: "4.0.0"), diff --git a/Sources/hyper-focus/configuration_loader.swift b/Sources/hyper-focus/configuration_loader.swift index 563f2b4..62ca873 100644 --- a/Sources/hyper-focus/configuration_loader.swift +++ b/Sources/hyper-focus/configuration_loader.swift @@ -21,7 +21,13 @@ enum ConfigurationLoader { debug("Loading configuration from \(configPath!.absoluteString)") let configData = try! Data(contentsOf: configPath!) - let config = try! JSONDecoder().decode(Configuration.self, from: configData) + + // neat! Apple supports JSON5, which allows for comments + // https://developer.apple.com/documentation/foundation/jsondecoder/3766916-allowsjson5 + let decoder = JSONDecoder() + decoder.allowsJSON5 = true + + let config = try! decoder.decode(Configuration.self, from: configData) return config }