xtool.git
Publicgit clone https://git.maproj.org/xtool.gitxtool.git / macOS / XToolMac / XToolMac.swift
XToolMac.swift24 lines · 691 BRaw
| 1 | import Foundation |
| 2 | import Dependencies |
| 3 | import XToolSupport |
| 4 | import XKit |
| 5 | |
| 6 | @main enum XToolMacMain { |
| 7 | static func main() async throws { |
| 8 | // the bin/xtool script invokes us with this env var, allowing us to |
| 9 | // detect command-line invocations vs a UI app launch |
| 10 | if ProcessInfo.processInfo.environment["XTL_CLI"] == "1" { |
| 11 | try await runXTool() |
| 12 | } else { |
| 13 | XToolMacUI.main() |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | private static func runXTool() async throws { |
| 18 | try await withDependencies { |
| 19 | $0.keyValueStorage = KeychainStorage(service: "sh.xtool.keychain.credentials") |
| 20 | } operation: { |
| 21 | try await XTool.run() |
| 22 | } |
| 23 | } |
| 24 | } |