2024-11-10 17:51:53 +11:00
|
|
|
/*
|
|
|
|
* darwin-apk © 2024 Gay Pizza Specifications
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2024-11-08 21:22:33 +11:00
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import ArgumentParser
|
|
|
|
import darwin_apk
|
|
|
|
|
2024-11-16 00:30:19 +11:00
|
|
|
struct DpkUpdateCommand: AsyncParsableCommand {
|
2024-11-08 21:22:33 +11:00
|
|
|
static let configuration = CommandConfiguration(
|
|
|
|
commandName: "update",
|
|
|
|
abstract: "Update the system package repositories.",
|
|
|
|
aliases: [ "u" ])
|
|
|
|
|
2024-11-17 02:31:44 +11:00
|
|
|
@Flag(help: "Index on-disk cache")
|
|
|
|
var lazyDownload: Bool = false
|
|
|
|
|
2024-11-16 00:30:19 +11:00
|
|
|
func run() async throws {
|
2024-11-17 02:31:44 +11:00
|
|
|
let repositories = try await ApkRepositoriesConfig().repositories
|
2024-11-17 02:59:13 +11:00
|
|
|
eprint("Updating package repositories")
|
2024-11-22 21:01:01 +11:00
|
|
|
let index = try await ApkIndexReader.resolve(repositories, fetch: self.lazyDownload ? .lazy : .update)
|
2024-11-17 02:59:13 +11:00
|
|
|
eprint("Indexed \(index.packages.count) package(s)")
|
2024-11-08 21:22:33 +11:00
|
|
|
}
|
|
|
|
}
|