Skip to content

Commit ac0df43

Browse files
committed
remove --disable-progress-updates + add --progress option
1 parent f2b3cbd commit ac0df43

File tree

7 files changed

+42
-37
lines changed

7 files changed

+42
-37
lines changed

Sources/ContainerClient/Flags.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,4 @@ public struct Flags {
201201
public var virtualization: Bool = false
202202
}
203203

204-
public struct Progress: ParsableArguments {
205-
public init() {}
206-
207-
public init(disableProgressUpdates: Bool) {
208-
self.disableProgressUpdates = disableProgressUpdates
209-
}
210-
211-
@Flag(name: .long, help: "Disable progress bar updates")
212-
public var disableProgressUpdates = false
213-
}
214204
}

Sources/ContainerCommands/Container/ContainerRun.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ extension Application {
3232
commandName: "run",
3333
abstract: "Run a container")
3434

35+
enum ProgressType: String, ExpressibleByArgument {
36+
case none
37+
case ansi
38+
}
39+
3540
@OptionGroup(title: "Process options")
3641
var processFlags: Flags.Process
3742

@@ -44,8 +49,8 @@ extension Application {
4449
@OptionGroup(title: "Registry options")
4550
var registryFlags: Flags.Registry
4651

47-
@OptionGroup(title: "Progress options")
48-
var progressFlags: Flags.Progress
52+
@Option(name: .long, help: ArgumentHelp("Progress type (format: none|ansi)", valueName: "type"))
53+
var progress: ProgressType = .ansi
4954

5055
@OptionGroup
5156
var global: Flags.Global
@@ -61,9 +66,9 @@ extension Application {
6166
let id = Utility.createContainerID(name: self.managementFlags.name)
6267

6368
var progressConfig: ProgressConfig
64-
if progressFlags.disableProgressUpdates {
65-
progressConfig = try ProgressConfig(disableProgressUpdates: progressFlags.disableProgressUpdates)
66-
} else {
69+
switch self.progress {
70+
case .none: progressConfig = try ProgressConfig(disableProgressUpdates: true)
71+
case .ansi:
6772
progressConfig = try ProgressConfig(
6873
showTasks: true,
6974
showItems: true,

Sources/ContainerCommands/Image/ImagePull.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ extension Application {
2828
abstract: "Pull an image"
2929
)
3030

31+
enum ProgressType: String, ExpressibleByArgument {
32+
case none
33+
case ansi
34+
}
35+
3136
@OptionGroup
3237
var global: Flags.Global
3338

3439
@OptionGroup
3540
var registry: Flags.Registry
3641

37-
@OptionGroup
38-
var progressFlags: Flags.Progress
42+
@Option(name: .long, help: ArgumentHelp("Progress type (format: none|ansi)", valueName: "type"))
43+
var progress: ProgressType = .ansi
3944

4045
@Option(
4146
name: .shortAndLong,
@@ -57,10 +62,9 @@ extension Application {
5762

5863
public init() {}
5964

60-
public init(platform: String? = nil, scheme: String = "auto", reference: String, disableProgress: Bool = false) {
65+
public init(platform: String? = nil, scheme: String = "auto", reference: String) {
6166
self.global = Flags.Global()
6267
self.registry = Flags.Registry(scheme: scheme)
63-
self.progressFlags = Flags.Progress(disableProgressUpdates: disableProgress)
6468
self.platform = platform
6569
self.reference = reference
6670
}
@@ -80,9 +84,9 @@ extension Application {
8084
let processedReference = try ClientImage.normalizeReference(reference)
8185

8286
var progressConfig: ProgressConfig
83-
if self.progressFlags.disableProgressUpdates {
84-
progressConfig = try ProgressConfig(disableProgressUpdates: self.progressFlags.disableProgressUpdates)
85-
} else {
87+
switch self.progress {
88+
case .none: progressConfig = try ProgressConfig(disableProgressUpdates: true)
89+
case .ansi:
8690
progressConfig = try ProgressConfig(
8791
showTasks: true,
8892
showItems: true,

Sources/ContainerCommands/Image/ImagePush.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import ArgumentParser
1818
import ContainerClient
1919
import Containerization
20+
import ContainerizationError
2021
import ContainerizationOCI
2122
import TerminalProgress
2223

@@ -27,11 +28,16 @@ extension Application {
2728
abstract: "Push an image"
2829
)
2930

31+
enum ProgressType: String, ExpressibleByArgument {
32+
case none
33+
case ansi
34+
}
35+
3036
@OptionGroup
3137
var registry: Flags.Registry
3238

33-
@OptionGroup
34-
var progressFlags: Flags.Progress
39+
@Option(name: .long, help: ArgumentHelp("Progress type (format: none|ansi)", valueName: "type"))
40+
var progress: ProgressType = .ansi
3541

3642
@Option(
3743
name: [.customLong("arch"), .customShort("a")],
@@ -68,9 +74,9 @@ extension Application {
6874
let image = try await ClientImage.get(reference: reference)
6975

7076
var progressConfig: ProgressConfig
71-
if progressFlags.disableProgressUpdates {
72-
progressConfig = try ProgressConfig(disableProgressUpdates: progressFlags.disableProgressUpdates)
73-
} else {
77+
switch self.progress {
78+
case .none: progressConfig = try ProgressConfig(disableProgressUpdates: true)
79+
case .ansi:
7480
progressConfig = try ProgressConfig(
7581
description: "Pushing image \(image.reference)",
7682
itemsName: "blobs",
@@ -79,6 +85,7 @@ extension Application {
7985
ignoreSmallSize: true
8086
)
8187
}
88+
8289
let progress = ProgressBar(config: progressConfig)
8390
defer {
8491
progress.finish()

Tests/CLITests/Subcommands/Build/CLIRunBase.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class TestCLIRunBase: CLITest {
4242
nil
4343
}
4444

45-
var DisableProgressUpdates: Bool {
46-
false
45+
var Progress: String {
46+
"ansi"
4747
}
4848

4949
override init() throws {
@@ -115,9 +115,8 @@ class TestCLIRunBase: CLITest {
115115
if Tty { arguments.append("-t") }
116116
}
117117

118-
if DisableProgressUpdates {
119-
arguments.append("--disable-progress-updates")
120-
}
118+
arguments.append("--progress")
119+
arguments.append(Progress)
121120

122121
if let entrypoint = Entrypoint {
123122
arguments += ["--entrypoint", entrypoint]

Tests/CLITests/Subcommands/Build/TestCLITermIO.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ extension TestCLIRunBase {
3636
["/bin/sh"]
3737
}
3838

39-
override var DisableProgressUpdates: Bool {
40-
true
39+
override var Progress: String {
40+
"none"
4141
}
4242

4343
@Test func testTermIODoesNotPanic() async throws {

docs/command-reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ container run [OPTIONS] IMAGE [COMMAND] [ARG...]
6868
For internal/local registries, the client uses **HTTP**. Otherwise, it uses **HTTPS**.
6969

7070
* **Progress options**
71-
* `--disable-progress-updates`: Disable progress bar updates
71+
* `--progress <type>`: Progress type (format: none|ansi) (default: ansi)
7272
* **Global options**
7373
* `--debug`: Enable debug output [environment: CONTAINER_DEBUG]
7474
* `--version`: Show the version.
@@ -370,7 +370,7 @@ container image pull [OPTIONS] REFERENCE
370370

371371
* `--platform <platform>`: Platform string in the form `os/arch/variant`. Example `linux/arm64/v8`, `linux/amd64`. Default: current host platform.
372372
* `--scheme <scheme>`: Scheme to use when connecting to the container registry. One of (`http`, `https`, `auto`) (default: `auto`)
373-
* `--disable-progress-updates`: Disable progress bar updates
373+
* `--progress <type>`: Progress type (format: none|ansi) (default: ansi)
374374
* **Global**: `--debug`, `--version`, `-h`/`--help`
375375

376376
### `container image push`
@@ -387,7 +387,7 @@ container image push [OPTIONS] REFERENCE
387387

388388
* `--platform <platform>`: Platform string in the form `os/arch/variant`. Example `linux/arm64/v8`, `linux/amd64` (optional)
389389
* `--scheme <scheme>`: Scheme to use when connecting to the container registry. One of (`http`, `https`, `auto`) (default: `auto`)
390-
* `--disable-progress-updates`: Disable progress bar updates
390+
* `--progress <type>`: Progress type (format: none|ansi) (default: ansi)
391391
* **Global**: `--debug`, `--version`, `-h`/`--help`
392392

393393
### `container image save`

0 commit comments

Comments
 (0)