diff --git a/Sources/Command/Measure.swift b/Sources/Command/Measure.swift index 398a695..c540e9d 100644 --- a/Sources/Command/Measure.swift +++ b/Sources/Command/Measure.swift @@ -143,13 +143,13 @@ extension LCLCLI { #if DEBUG print(configuration ?? "Empty configuration") #endif - let siteMap = Dictionary(uniqueKeysWithValues: sites.map { ($0.name, $0) }) - guard let cellSiteName = configuration?.cellSiteName else { - throw CLIError.invalidConfiguration("Missing cellular site name.") + let siteMap = Dictionary(uniqueKeysWithValues: sites.map { ($0._id, $0) }) + guard let cellSiteId = configuration?.cellSiteId else { + throw CLIError.invalidConfiguration("Missing cellular site ID.") } - guard let ss = siteMap[cellSiteName] else { - throw CLIError.invalidConfiguration("Invalid cellular site name.") + guard let ss = siteMap[cellSiteId] else { + throw CLIError.invalidConfiguration("Invalid cellular site ID.") } selectedSite = ss } diff --git a/Sources/Models/CellularSite.swift b/Sources/Models/CellularSite.swift index 9b62d3a..554060e 100644 --- a/Sources/Models/CellularSite.swift +++ b/Sources/Models/CellularSite.swift @@ -14,8 +14,9 @@ import Foundation import SwiftyTextTable struct CellularSite: Decodable, Identifiable { - var id: String { name } + var id: String { _id } + let _id: String let address: String let cellId: [String] let latitude: Double @@ -27,6 +28,7 @@ struct CellularSite: Decodable, Identifiable { extension CellularSite { enum CodingKeys: String, CodingKey { + case _id = "_id" case name = "name" case latitude = "latitude" case longitude = "longitude" diff --git a/Sources/Models/Configuration.swift b/Sources/Models/Configuration.swift index 965ffb3..a618d3b 100644 --- a/Sources/Models/Configuration.swift +++ b/Sources/Models/Configuration.swift @@ -13,6 +13,6 @@ import Foundation struct Configuration: Decodable { - let cellSiteName: String + let cellSiteId: String let deviceName: String } diff --git a/example_config.json b/example_config.json index f4bcb61..5f68705 100644 --- a/example_config.json +++ b/example_config.json @@ -1,4 +1,4 @@ { - "cellSiteName": "ICTD Lab Testbed", + "cellSiteId": "6897d0a3cab397620dbda931", "deviceName": "test device" }