mirror of
https://github.com/GayPizzaSpecifications/darwin-apk.git
synced 2025-08-04 05:51:31 +00:00
prefer to print to stderr for console chatter
This commit is contained in:
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* darwin-apk © 2024 Gay Pizza Specifications
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import ArgumentParser
|
||||
|
||||
public struct ApkRepositoriesConfig {
|
||||
public let repositories: [ApkIndexRepository]
|
||||
|
||||
public init() async throws(ExitCode) {
|
||||
do {
|
||||
self.repositories = try await Self.readConfig(name: "repositories").flatMap { repo in
|
||||
Self.readConfig(name: "arch").map { arch in
|
||||
ApkIndexRepository(name: repo, arch: arch)
|
||||
}
|
||||
}.reduce(into: []) { $0.append($1) }
|
||||
} catch {
|
||||
print("Failed to read repository configurations, \(error.localizedDescription)")
|
||||
throw .failure
|
||||
}
|
||||
}
|
||||
|
||||
private static func readConfig(name: String)
|
||||
-> AsyncFilterSequence<AsyncMapSequence<AsyncLineSequence<URL.AsyncBytes>, String>> {
|
||||
return URL(filePath: name, directoryHint: .notDirectory).lines
|
||||
.map { $0.trimmingCharacters(in: .whitespaces) }
|
||||
.filter { !$0.isEmpty && $0.first != "#" } // Ignore empty & commented lines
|
||||
}
|
||||
}
|
||||
|
||||
public extension ApkIndex {
|
||||
@inlinable static func resolve(_ config: ApkRepositoriesConfig, fetch: ApkIndexFetchMode) async throws -> Self {
|
||||
try await Self.resolve(config.repositories, fetch: fetch)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user