Skip to content

Commit

Permalink
Fix cask info key names
Browse files Browse the repository at this point in the history
  • Loading branch information
milanvarady committed Jan 2, 2025
1 parent 0f6d94a commit 6a33f52
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
20 changes: 12 additions & 8 deletions Applite/Model/Cask Models/CaskAdditionalInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,35 @@ struct CaskAdditionalInfo: Codable, Hashable {
let url: URL
/// Installed version
let installed: String?
let bundle_version: String?
let installed_time: Date?
let outdated: Bool?
let auto_updates: Bool?
let deprecated: Bool
let deprection_date: Date?
let deprecation_date: String?
let deprecation_reason: String?
let deprecation_replacement: String?
let disabled: Bool
let disabled_date: Date?
let disabled_reason: String?
let disabled_replacement: String?
let disable_date: String?
let disable_reason: String?
let disable_replacement: String?

static let dummy = CaskAdditionalInfo(
token: "Applite", tap: "homebrew/cask",
homepage: URL(string: "https://aerolite.dev/applite")!,
url: URL(string: "https://github.com/milanvarady/Applite/releases/download/v1.2.5/Applite.dmg")!,
installed: "1.2.5",
bundle_version: "1.2.5",
installed_time: Date(timeIntervalSince1970: 1735754762),
outdated: false,
auto_updates: true,
deprecated: false,
deprection_date: nil,
deprecation_date: nil,
deprecation_reason: nil,
deprecation_replacement: nil,
disabled: false,
disabled_date: nil,
disabled_reason: nil,
disabled_replacement: nil
disable_date: nil,
disable_reason: nil,
disable_replacement: nil
)
}
4 changes: 4 additions & 0 deletions Applite/Views/App Views/App View/AppView+GetInfoButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import OSLog

extension AppView {
struct GetInfoButton: View {
Expand All @@ -15,6 +16,8 @@ extension AppView {

@StateObject var alert = AlertManager()

private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "GetInfoButton")

var body: some View {
Button {
Task {
Expand All @@ -23,6 +26,7 @@ extension AppView {
openWindow(value: caskInfo)
} catch {
alert.show(error: error, title: "Failed to gather cask info")
logger.error("Failed to gather additional cask info: \(error.localizedDescription)")
}
}
} label: {
Expand Down
25 changes: 16 additions & 9 deletions Applite/Views/Windows/CaskInfoWindowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,25 @@ struct CaskInfoWindowView: View {
Row(property: "Homepage", value: info.homepage.absoluteString, url: info.homepage),
Row(property: "URL", value: info.url.absoluteString, url: info.url),
Row(property: "Installed Version", value: info.installed ?? "Not installed"),
Row(property: "Auto Updates", value: (info.auto_updates ?? false) ? "Yes" : "No"),
Row(property: "Deprecated", value: info.deprecated ? "Yes" : "No"),
Row(property: "Disabled", value: info.disabled ? "Yes" : "No")
Row(property: "Bundle Version", value: info.bundle_version ?? "Not installed"),
Row(property: "Auto Updates", value: (info.auto_updates ?? false) ? "Yes" : "No")
]

if let outdated = info.outdated {
result.append(Row(property: "Outdated", value: outdated ? "Yes" : "No"))
}

if let installedTime = info.installed_time {
result.append(Row(property: "Installation Date",
value: dateFormatter.string(from: installedTime)))
}

result.append(Row(property: "Deprecated", value: info.deprecated ? "Yes" : "No"))

if info.deprecated {
if let date = info.deprection_date {
if let date = info.deprecation_date {
result.append(Row(property: "Deprecation Date",
value: dateFormatter.string(from: date)))
value: date))
}
if let reason = info.deprecation_reason {
result.append(Row(property: "Deprecation Reason", value: reason))
Expand All @@ -79,15 +84,17 @@ struct CaskInfoWindowView: View {
}
}

result.append(Row(property: "Disabled", value: info.disabled ? "Yes" : "No"))

if info.disabled {
if let date = info.disabled_date {
if let date = info.disable_date {
result.append(Row(property: "Disabled Date",
value: dateFormatter.string(from: date)))
value: date))
}
if let reason = info.disabled_reason {
if let reason = info.disable_reason {
result.append(Row(property: "Disabled Reason", value: reason))
}
if let replacement = info.disabled_replacement {
if let replacement = info.disable_replacement {
result.append(Row(property: "Disabled Replacement", value: replacement))
}
}
Expand Down

0 comments on commit 6a33f52

Please sign in to comment.