mirror of
https://github.com/apple/container.git
synced 2026-07-12 20:47:04 +00:00
[options]: Replace --disable-progress-updates with --progress (none | ansi) (#808)
Part 1 of #641
This commit is contained in:
@@ -204,11 +204,12 @@ public struct Flags {
|
||||
public struct Progress: ParsableArguments {
|
||||
public init() {}
|
||||
|
||||
public init(disableProgressUpdates: Bool) {
|
||||
self.disableProgressUpdates = disableProgressUpdates
|
||||
public enum ProgressType: String, ExpressibleByArgument {
|
||||
case none
|
||||
case ansi
|
||||
}
|
||||
|
||||
@Flag(name: .long, help: "Disable progress bar updates")
|
||||
public var disableProgressUpdates = false
|
||||
@Option(name: .long, help: ArgumentHelp("Progress type (format: none|ansi)", valueName: "type"))
|
||||
public var progress: ProgressType = .ansi
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ extension Application {
|
||||
let id = Utility.createContainerID(name: self.managementFlags.name)
|
||||
|
||||
var progressConfig: ProgressConfig
|
||||
if progressFlags.disableProgressUpdates {
|
||||
progressConfig = try ProgressConfig(disableProgressUpdates: progressFlags.disableProgressUpdates)
|
||||
} else {
|
||||
switch self.progressFlags.progress {
|
||||
case .none: progressConfig = try ProgressConfig(disableProgressUpdates: true)
|
||||
case .ansi:
|
||||
progressConfig = try ProgressConfig(
|
||||
showTasks: true,
|
||||
showItems: true,
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
import ArgumentParser
|
||||
import ContainerClient
|
||||
import Containerization
|
||||
import ContainerizationError
|
||||
import ContainerizationOCI
|
||||
import TerminalProgress
|
||||
|
||||
@@ -57,10 +56,9 @@ extension Application {
|
||||
|
||||
public init() {}
|
||||
|
||||
public init(platform: String? = nil, scheme: String = "auto", reference: String, disableProgress: Bool = false) {
|
||||
public init(platform: String? = nil, scheme: String = "auto", reference: String) {
|
||||
self.global = Flags.Global()
|
||||
self.registry = Flags.Registry(scheme: scheme)
|
||||
self.progressFlags = Flags.Progress(disableProgressUpdates: disableProgress)
|
||||
self.platform = platform
|
||||
self.reference = reference
|
||||
}
|
||||
@@ -80,9 +78,9 @@ extension Application {
|
||||
let processedReference = try ClientImage.normalizeReference(reference)
|
||||
|
||||
var progressConfig: ProgressConfig
|
||||
if self.progressFlags.disableProgressUpdates {
|
||||
progressConfig = try ProgressConfig(disableProgressUpdates: self.progressFlags.disableProgressUpdates)
|
||||
} else {
|
||||
switch self.progressFlags.progress {
|
||||
case .none: progressConfig = try ProgressConfig(disableProgressUpdates: true)
|
||||
case .ansi:
|
||||
progressConfig = try ProgressConfig(
|
||||
showTasks: true,
|
||||
showItems: true,
|
||||
|
||||
@@ -68,9 +68,9 @@ extension Application {
|
||||
let image = try await ClientImage.get(reference: reference)
|
||||
|
||||
var progressConfig: ProgressConfig
|
||||
if progressFlags.disableProgressUpdates {
|
||||
progressConfig = try ProgressConfig(disableProgressUpdates: progressFlags.disableProgressUpdates)
|
||||
} else {
|
||||
switch self.progressFlags.progress {
|
||||
case .none: progressConfig = try ProgressConfig(disableProgressUpdates: true)
|
||||
case .ansi:
|
||||
progressConfig = try ProgressConfig(
|
||||
description: "Pushing image \(image.reference)",
|
||||
itemsName: "blobs",
|
||||
@@ -79,6 +79,7 @@ extension Application {
|
||||
ignoreSmallSize: true
|
||||
)
|
||||
}
|
||||
|
||||
let progress = ProgressBar(config: progressConfig)
|
||||
defer {
|
||||
progress.finish()
|
||||
|
||||
@@ -22,28 +22,28 @@ class TestCLIRunBase: CLITest {
|
||||
var terminal: Terminal!
|
||||
var containerName: String = UUID().uuidString
|
||||
|
||||
var ContainerImage: String {
|
||||
var containerImage: String {
|
||||
fatalError("Subclasses must override this property")
|
||||
}
|
||||
|
||||
var Interactive: Bool {
|
||||
var interactive: Bool {
|
||||
false
|
||||
}
|
||||
|
||||
var Tty: Bool {
|
||||
var tty: Bool {
|
||||
false
|
||||
}
|
||||
|
||||
var Entrypoint: String? {
|
||||
var entrypoint: String? {
|
||||
nil
|
||||
}
|
||||
|
||||
var Command: [String]? {
|
||||
var command: [String]? {
|
||||
nil
|
||||
}
|
||||
|
||||
var DisableProgressUpdates: Bool {
|
||||
false
|
||||
var progress: String {
|
||||
"ansi"
|
||||
}
|
||||
|
||||
override init() throws {
|
||||
@@ -108,24 +108,23 @@ class TestCLIRunBase: CLITest {
|
||||
name,
|
||||
]
|
||||
|
||||
if Interactive && Tty {
|
||||
if interactive && tty {
|
||||
arguments.append("-it")
|
||||
} else {
|
||||
if Interactive { arguments.append("-i") }
|
||||
if Tty { arguments.append("-t") }
|
||||
if interactive { arguments.append("-i") }
|
||||
if tty { arguments.append("-t") }
|
||||
}
|
||||
|
||||
if DisableProgressUpdates {
|
||||
arguments.append("--disable-progress-updates")
|
||||
}
|
||||
arguments.append("--progress")
|
||||
arguments.append(progress)
|
||||
|
||||
if let entrypoint = Entrypoint {
|
||||
if let entrypoint = entrypoint {
|
||||
arguments += ["--entrypoint", entrypoint]
|
||||
}
|
||||
|
||||
arguments.append(ContainerImage)
|
||||
arguments.append(containerImage)
|
||||
|
||||
if let command = Command {
|
||||
if let command = command {
|
||||
arguments += command
|
||||
}
|
||||
return try runInteractive(arguments: arguments)
|
||||
|
||||
@@ -20,24 +20,24 @@ import Testing
|
||||
|
||||
extension TestCLIRunBase {
|
||||
class TestCLITermIO: TestCLIRunBase {
|
||||
override var ContainerImage: String {
|
||||
override var containerImage: String {
|
||||
"ghcr.io/linuxcontainers/alpine:3.20"
|
||||
}
|
||||
|
||||
override var Interactive: Bool {
|
||||
override var interactive: Bool {
|
||||
true
|
||||
}
|
||||
|
||||
override var Tty: Bool {
|
||||
override var tty: Bool {
|
||||
true
|
||||
}
|
||||
|
||||
override var Command: [String]? {
|
||||
override var command: [String]? {
|
||||
["/bin/sh"]
|
||||
}
|
||||
|
||||
override var DisableProgressUpdates: Bool {
|
||||
true
|
||||
override var progress: String {
|
||||
"none"
|
||||
}
|
||||
|
||||
@Test func testTermIODoesNotPanic() async throws {
|
||||
|
||||
@@ -79,7 +79,7 @@ container run [<options>] <image> [<arguments> ...]
|
||||
|
||||
**Progress Options**
|
||||
|
||||
* `--disable-progress-updates`: Disable progress bar updates
|
||||
* `--progress <type>`: Progress type (format: none|ansi) (default: ansi)
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -395,7 +395,7 @@ Pulls an image from a registry. Supports specifying a platform and controlling p
|
||||
**Usage**
|
||||
|
||||
```bash
|
||||
container image pull [--debug] [--scheme <scheme>] [--disable-progress-updates] [--arch <arch>] [--os <os>] [--platform <platform>] <reference>
|
||||
container image pull [--debug] [--scheme <scheme>] [--progress <type>] [--arch <arch>] [--os <os>] [--platform <platform>] <reference>
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
@@ -405,7 +405,7 @@ container image pull [--debug] [--scheme <scheme>] [--disable-progress-updates]
|
||||
**Options**
|
||||
|
||||
* `--scheme <scheme>`: Scheme to use when connecting to the container registry. One of (http, https, auto) (default: auto)
|
||||
* `--disable-progress-updates`: Disable progress bar updates
|
||||
* `--progress <type>`: Progress type (format: none|ansi) (default: ansi)
|
||||
* `-a, --arch <arch>`: Limit the pull to the specified architecture
|
||||
* `--os <os>`: Limit the pull to the specified OS
|
||||
* `--platform <platform>`: Limit the pull to the specified platform (format: os/arch[/variant], takes precedence over --os and --arch)
|
||||
@@ -417,7 +417,7 @@ Pushes an image to a registry. The flags mirror those for `image pull` with the
|
||||
**Usage**
|
||||
|
||||
```bash
|
||||
container image push [--scheme <scheme>] [--disable-progress-updates] [--arch <arch>] [--os <os>] [--platform <platform>] [--debug] <reference>
|
||||
container image push [--scheme <scheme>] [--progress <type>] [--arch <arch>] [--os <os>] [--platform <platform>] [--debug] <reference>
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
@@ -427,7 +427,7 @@ container image push [--scheme <scheme>] [--disable-progress-updates] [--arch <a
|
||||
**Options**
|
||||
|
||||
* `--scheme <scheme>`: Scheme to use when connecting to the container registry. One of (http, https, auto) (default: auto)
|
||||
* `--disable-progress-updates`: Disable progress bar updates
|
||||
* `--progress <type>`: Progress type (format: none|ansi) (default: ansi)
|
||||
* `-a, --arch <arch>`: Limit the push to the specified architecture
|
||||
* `--os <os>`: Limit the push to the specified OS
|
||||
* `--platform <platform>`: Limit the push to the specified platform (format: os/arch[/variant], takes precedence over --os and --arch)
|
||||
|
||||
Reference in New Issue
Block a user