Files
darwin-apk/Sources/dpk-cli/Subcommands/DpkUpdateCommand.swift

26 lines
734 B
Swift
Raw Normal View History

2024-11-10 17:51:53 +11:00
/*
* darwin-apk © 2024 Gay Pizza Specifications
* SPDX-License-Identifier: Apache-2.0
*/
import Foundation
import ArgumentParser
import darwin_apk
struct DpkUpdateCommand: AsyncParsableCommand {
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
func run() async throws {
2024-11-17 02:31:44 +11:00
let repositories = try await ApkRepositoriesConfig().repositories
print("Updating package repositories")
2024-11-17 02:31:44 +11:00
let index = try await ApkIndex.resolve(repositories, fetch: self.lazyDownload ? .lazy : .update)
print("Indexed \(index.packages.count) package(s)")
}
}