From bcfcd5ac195c4f6fc82a092a922fcf77e33ac35c Mon Sep 17 00:00:00 2001 From: J Logan Date: Mon, 22 Sep 2025 13:18:20 -0700 Subject: [PATCH] Cleans up registry subcommand options. (#660) - Part of #515. - Order options alphabetically. ## Motivation and Context See #515. --- .../ContainerCommands/Network/NetworkDelete.swift | 4 ++-- Sources/ContainerCommands/Registry/Login.swift | 15 +++++++++------ Sources/ContainerCommands/Registry/Logout.swift | 6 +++--- .../Registry/RegistryCommand.swift | 5 +++-- .../ContainerCommands/Volume/VolumeDelete.swift | 2 -- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Sources/ContainerCommands/Network/NetworkDelete.swift b/Sources/ContainerCommands/Network/NetworkDelete.swift index 80e545e2..4df3374b 100644 --- a/Sources/ContainerCommands/Network/NetworkDelete.swift +++ b/Sources/ContainerCommands/Network/NetworkDelete.swift @@ -90,8 +90,8 @@ extension Application { for network in networks { group.addTask { do { - // delete atomically disables the IP allocator, then deletes - // the allocator disable fails if any IPs are still in use + // Delete atomically disables the IP allocator, then deletes + // the allocator. The disable fails if any IPs are still in use. try await ClientNetwork.delete(id: network.id) print(network.id) return nil diff --git a/Sources/ContainerCommands/Registry/Login.swift b/Sources/ContainerCommands/Registry/Login.swift index 3346f3fe..018e168d 100644 --- a/Sources/ContainerCommands/Registry/Login.swift +++ b/Sources/ContainerCommands/Registry/Login.swift @@ -25,20 +25,23 @@ extension Application { public struct Login: AsyncParsableCommand { public init() {} public static let configuration = CommandConfiguration( - abstract: "Login to a registry" + abstract: "Log in to a registry" ) - @Option(name: .shortAndLong, help: "Username") - var username: String = "" + @OptionGroup + var registry: Flags.Registry @Flag(help: "Take the password from stdin") var passwordStdin: Bool = false - @Argument(help: "Registry server name") - var server: String + @Option(name: .shortAndLong, help: "Registry user name") + var username: String = "" @OptionGroup - var registry: Flags.Registry + var global: Flags.Global + + @Argument(help: "Registry server name") + var server: String public func run() async throws { var username = self.username diff --git a/Sources/ContainerCommands/Registry/Logout.swift b/Sources/ContainerCommands/Registry/Logout.swift index ac115501..1eb27419 100644 --- a/Sources/ContainerCommands/Registry/Logout.swift +++ b/Sources/ContainerCommands/Registry/Logout.swift @@ -25,12 +25,12 @@ extension Application { public static let configuration = CommandConfiguration( abstract: "Log out from a registry") - @Argument(help: "Registry server name") - var registry: String - @OptionGroup var global: Flags.Global + @Argument(help: "Registry server name") + var registry: String + public func run() async throws { let keychain = KeychainHelper(id: Constants.keychainID) let r = Reference.resolveDomain(domain: registry) diff --git a/Sources/ContainerCommands/Registry/RegistryCommand.swift b/Sources/ContainerCommands/Registry/RegistryCommand.swift index 55c2fc1e..5a478204 100644 --- a/Sources/ContainerCommands/Registry/RegistryCommand.swift +++ b/Sources/ContainerCommands/Registry/RegistryCommand.swift @@ -18,15 +18,16 @@ import ArgumentParser extension Application { public struct RegistryCommand: AsyncParsableCommand { - public init() {} public static let configuration = CommandConfiguration( commandName: "registry", - abstract: "Manage registry configurations", + abstract: "Manage registry logins", subcommands: [ Login.self, Logout.self, ], aliases: ["r"] ) + + public init() {} } } diff --git a/Sources/ContainerCommands/Volume/VolumeDelete.swift b/Sources/ContainerCommands/Volume/VolumeDelete.swift index 54133d21..021d910d 100644 --- a/Sources/ContainerCommands/Volume/VolumeDelete.swift +++ b/Sources/ContainerCommands/Volume/VolumeDelete.swift @@ -71,8 +71,6 @@ extension Application.VolumeCommand { for volume in volumes { group.addTask { do { - // delete atomically disables the IP allocator, then deletes - // the allocator disable fails if any IPs are still in use try await ClientVolume.delete(name: volume.id) print(volume.id) return nil