mirror of
				https://github.com/GayPizzaSpecifications/darwin-apk.git
				synced 2025-11-04 07:59:38 +00:00 
			
		
		
		
	Initial implementation of APKINDEX, fetching, reading, parsing, & merging
This commit is contained in:
		@ -8,68 +8,9 @@ struct DarwinApkCLI: ParsableCommand {
 | 
			
		||||
    commandName: "dpk",
 | 
			
		||||
    abstract: "Command-line interface for managing packages installed via darwin-apk.",
 | 
			
		||||
    subcommands: [
 | 
			
		||||
      Install.self,
 | 
			
		||||
      Remove.self,
 | 
			
		||||
      Update.self,
 | 
			
		||||
      Upgrade.self
 | 
			
		||||
      DpkInstallCommand.self,
 | 
			
		||||
      DpkRemoveCommand.self,
 | 
			
		||||
      DpkUpdateCommand.self,
 | 
			
		||||
      DpkUpgradeCommand.self
 | 
			
		||||
    ])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
extension DarwinApkCLI {
 | 
			
		||||
  struct Install: ParsableCommand {
 | 
			
		||||
    static let configuration = CommandConfiguration(
 | 
			
		||||
      commandName: "add",
 | 
			
		||||
      abstract: "Install package(s) to the system.",
 | 
			
		||||
      aliases: [ "install", "i", "a" ])
 | 
			
		||||
 | 
			
		||||
    @Argument(help: "One or more package names to install to the system.")
 | 
			
		||||
    var packages: [String]
 | 
			
		||||
 | 
			
		||||
    func run() throws {
 | 
			
		||||
      print("installing \"\(packages.joined(separator: "\", \""))\"")
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  struct Remove: ParsableCommand {
 | 
			
		||||
    static let configuration = CommandConfiguration(
 | 
			
		||||
      commandName: "remove",
 | 
			
		||||
      abstract: "Remove specified package(s) from the system.",
 | 
			
		||||
      aliases: [ "uninstall", "del", "rem", "r" ])
 | 
			
		||||
 | 
			
		||||
    @Argument(help: "One or more package names to uninstall from the system.")
 | 
			
		||||
    var packages: [String]
 | 
			
		||||
 | 
			
		||||
    func run() throws {
 | 
			
		||||
      print("uninstalling \"\(packages.joined(separator: "\", \""))\"")
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  struct Update: ParsableCommand {
 | 
			
		||||
    static let configuration = CommandConfiguration(
 | 
			
		||||
      commandName: "update",
 | 
			
		||||
      abstract: "Update the system package repositories.",
 | 
			
		||||
      aliases: [ "u" ])
 | 
			
		||||
 | 
			
		||||
    func run() throws {
 | 
			
		||||
      print("updating package repositories")
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  struct Upgrade: ParsableCommand {
 | 
			
		||||
    static let configuration = CommandConfiguration(
 | 
			
		||||
      commandName: "upgrade",
 | 
			
		||||
      abstract: "Upgrade installed packages.",
 | 
			
		||||
      aliases: [ "U" ])
 | 
			
		||||
 | 
			
		||||
    @Argument(help: "Optionally specify packages to upgrade. Otherwise upgrade all packages installed on the system.")
 | 
			
		||||
    var packages: [String] = []
 | 
			
		||||
 | 
			
		||||
    func run() throws {
 | 
			
		||||
      if packages.isEmpty {
 | 
			
		||||
        print("upgrading system")
 | 
			
		||||
      } else {
 | 
			
		||||
        print("upgrading invidual packages: \"\(packages.joined(separator: "\", \""))\"")
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								Sources/dpk-cli/Subcommands/DpkInstallCommand.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Sources/dpk-cli/Subcommands/DpkInstallCommand.swift
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
// SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 | 
			
		||||
import ArgumentParser
 | 
			
		||||
 | 
			
		||||
struct DpkInstallCommand: ParsableCommand {
 | 
			
		||||
  static let configuration = CommandConfiguration(
 | 
			
		||||
    commandName: "add",
 | 
			
		||||
    abstract: "Install package(s) to the system.",
 | 
			
		||||
    aliases: [ "a", "install" ])
 | 
			
		||||
 | 
			
		||||
  @Argument(help: "One or more package names to install to the system.")
 | 
			
		||||
  var packages: [String]
 | 
			
		||||
 | 
			
		||||
  func run() throws {
 | 
			
		||||
    print("installing \"\(packages.joined(separator: "\", \""))\"")
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										17
									
								
								Sources/dpk-cli/Subcommands/DpkRemoveCommand.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Sources/dpk-cli/Subcommands/DpkRemoveCommand.swift
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
// SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 | 
			
		||||
import ArgumentParser
 | 
			
		||||
 | 
			
		||||
struct DpkRemoveCommand: ParsableCommand {
 | 
			
		||||
  static let configuration = CommandConfiguration(
 | 
			
		||||
    commandName: "remove",
 | 
			
		||||
    abstract: "Remove specified package(s) from the system.",
 | 
			
		||||
    aliases: [ "r", "rem", "del", "uninstall" ])
 | 
			
		||||
 | 
			
		||||
  @Argument(help: "One or more package(s) to uninstall from the system.")
 | 
			
		||||
  var packages: [String]
 | 
			
		||||
 | 
			
		||||
  func run() throws {
 | 
			
		||||
    print("uninstalling \"\(packages.joined(separator: "\", \""))\"")
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								Sources/dpk-cli/Subcommands/DpkUpdateCommand.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								Sources/dpk-cli/Subcommands/DpkUpdateCommand.swift
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
// SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 | 
			
		||||
import Foundation
 | 
			
		||||
import ArgumentParser
 | 
			
		||||
import darwin_apk
 | 
			
		||||
 | 
			
		||||
struct DpkUpdateCommand: ParsableCommand {
 | 
			
		||||
  static let configuration = CommandConfiguration(
 | 
			
		||||
    commandName: "update",
 | 
			
		||||
    abstract: "Update the system package repositories.",
 | 
			
		||||
    aliases: [ "u" ])
 | 
			
		||||
 | 
			
		||||
  func run() throws {
 | 
			
		||||
    print("Updating package repositories")
 | 
			
		||||
    var updater = ApkIndexUpdater()
 | 
			
		||||
    updater.update()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										21
									
								
								Sources/dpk-cli/Subcommands/DpkUpgradeCommand.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								Sources/dpk-cli/Subcommands/DpkUpgradeCommand.swift
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
			
		||||
// SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 | 
			
		||||
import ArgumentParser
 | 
			
		||||
 | 
			
		||||
struct DpkUpgradeCommand: ParsableCommand {
 | 
			
		||||
  static let configuration = CommandConfiguration(
 | 
			
		||||
    commandName: "upgrade",
 | 
			
		||||
    abstract: "Upgrade installed packages.",
 | 
			
		||||
    aliases: [ "U" ])
 | 
			
		||||
 | 
			
		||||
  @Argument(help: "Optionally specify packages to upgrade. Otherwise upgrade all packages installed on the system.")
 | 
			
		||||
  var packages: [String] = []
 | 
			
		||||
 | 
			
		||||
  func run() throws {
 | 
			
		||||
    if packages.isEmpty {
 | 
			
		||||
      print("upgrading system")
 | 
			
		||||
    } else {
 | 
			
		||||
      print("upgrading invidual packages: \"\(packages.joined(separator: "\", \""))\"")
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user