From a25a6be4059b83cc91ee3faa75387b887ff33306 Mon Sep 17 00:00:00 2001 From: Andrew Basson Date: Mon, 6 Oct 2025 14:22:21 +0200 Subject: [PATCH 1/5] fix: add version command and arg Signed-off-by: Andrew Basson --- Sources/Container-Compose/Application.swift | 5 ++- .../Container-Compose/Commands/Version.swift | 38 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 Sources/Container-Compose/Commands/Version.swift diff --git a/Sources/Container-Compose/Application.swift b/Sources/Container-Compose/Application.swift index 8327a0ab..59fae615 100644 --- a/Sources/Container-Compose/Application.swift +++ b/Sources/Container-Compose/Application.swift @@ -10,11 +10,14 @@ import ArgumentParser @main struct Main: AsyncParsableCommand { + static let version: String = "v0.5.1" static let configuration: CommandConfiguration = .init( commandName: "container-compose", abstract: "A tool to use manage Docker Compose files with Apple Container", + version: Self.version, subcommands: [ ComposeUp.self, - ComposeDown.self + ComposeDown.self, + Version.self ]) } diff --git a/Sources/Container-Compose/Commands/Version.swift b/Sources/Container-Compose/Commands/Version.swift new file mode 100644 index 00000000..554eaec7 --- /dev/null +++ b/Sources/Container-Compose/Commands/Version.swift @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// Copyright © 2025 Apple Inc. and the container project authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//===----------------------------------------------------------------------===// + +// +// Version.swift +// Container-Compose +// +// Created by Container Compose Contributors +// + +import ArgumentParser +import Foundation + +public struct Version: ParsableCommand { + public init() {} + + public static let configuration: CommandConfiguration = .init( + commandName: "version", + abstract: "Display the version information" + ) + + public func run() { + print("Container Compose version \(Main.version)") + } +} From 6d26c3f3109f9ba105b1023a1d3ec73cf183d82c Mon Sep 17 00:00:00 2001 From: Andrew Basson Date: Mon, 6 Oct 2025 21:22:25 +0200 Subject: [PATCH 2/5] fix: standardise the output of version and --version Signed-off-by: Andrew Basson --- Sources/Container-Compose/Application.swift | 8 ++++++-- Sources/Container-Compose/Commands/Version.swift | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Sources/Container-Compose/Application.swift b/Sources/Container-Compose/Application.swift index 59fae615..d7c9e5f8 100644 --- a/Sources/Container-Compose/Application.swift +++ b/Sources/Container-Compose/Application.swift @@ -10,11 +10,15 @@ import ArgumentParser @main struct Main: AsyncParsableCommand { + static let commandName: String = "container-compose" static let version: String = "v0.5.1" + static var versionString: String { + "\(commandName) version \(version)" + } static let configuration: CommandConfiguration = .init( - commandName: "container-compose", + commandName: Self.commandName, abstract: "A tool to use manage Docker Compose files with Apple Container", - version: Self.version, + version: Self.versionString, subcommands: [ ComposeUp.self, ComposeDown.self, diff --git a/Sources/Container-Compose/Commands/Version.swift b/Sources/Container-Compose/Commands/Version.swift index 554eaec7..b56f46bb 100644 --- a/Sources/Container-Compose/Commands/Version.swift +++ b/Sources/Container-Compose/Commands/Version.swift @@ -33,6 +33,6 @@ public struct Version: ParsableCommand { ) public func run() { - print("Container Compose version \(Main.version)") + print("\(Main.versionString)") } } From af8dab9f4d79d062d69bb108dee83a4d76d3c243 Mon Sep 17 00:00:00 2001 From: Andrew Basson Date: Tue, 7 Oct 2025 08:36:14 +0200 Subject: [PATCH 3/5] fix: scope version strings Signed-off-by: Andrew Basson --- Sources/Container-Compose/Application.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Container-Compose/Application.swift b/Sources/Container-Compose/Application.swift index d7c9e5f8..5b8400cd 100644 --- a/Sources/Container-Compose/Application.swift +++ b/Sources/Container-Compose/Application.swift @@ -10,9 +10,9 @@ import ArgumentParser @main struct Main: AsyncParsableCommand { - static let commandName: String = "container-compose" - static let version: String = "v0.5.1" - static var versionString: String { + private static let commandName: String = "container-compose" + private static let version: String = "v0.5.1" + public static var versionString: String { "\(commandName) version \(version)" } static let configuration: CommandConfiguration = .init( From 9363aaecb7c5803bf12c2c7c7c76c437ab60d83b Mon Sep 17 00:00:00 2001 From: Andrew Basson Date: Tue, 7 Oct 2025 08:52:29 +0200 Subject: [PATCH 4/5] fix: scope version command to internal Signed-off-by: Andrew Basson --- Sources/Container-Compose/Commands/Version.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Container-Compose/Commands/Version.swift b/Sources/Container-Compose/Commands/Version.swift index b56f46bb..70ce5a22 100644 --- a/Sources/Container-Compose/Commands/Version.swift +++ b/Sources/Container-Compose/Commands/Version.swift @@ -24,7 +24,7 @@ import ArgumentParser import Foundation -public struct Version: ParsableCommand { +internal struct Version: ParsableCommand { public init() {} public static let configuration: CommandConfiguration = .init( From a575658832c15e63a57b5b3b969e4766b15137da Mon Sep 17 00:00:00 2001 From: Andrew Basson Date: Wed, 8 Oct 2025 08:46:49 +0200 Subject: [PATCH 5/5] fix: cleanup more scopes Signed-off-by: Andrew Basson --- Sources/Container-Compose/Application.swift | 2 +- Sources/Container-Compose/Commands/Version.swift | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Sources/Container-Compose/Application.swift b/Sources/Container-Compose/Application.swift index 5b8400cd..774e5d56 100644 --- a/Sources/Container-Compose/Application.swift +++ b/Sources/Container-Compose/Application.swift @@ -12,7 +12,7 @@ import ArgumentParser struct Main: AsyncParsableCommand { private static let commandName: String = "container-compose" private static let version: String = "v0.5.1" - public static var versionString: String { + static var versionString: String { "\(commandName) version \(version)" } static let configuration: CommandConfiguration = .init( diff --git a/Sources/Container-Compose/Commands/Version.swift b/Sources/Container-Compose/Commands/Version.swift index 70ce5a22..164394fc 100644 --- a/Sources/Container-Compose/Commands/Version.swift +++ b/Sources/Container-Compose/Commands/Version.swift @@ -24,15 +24,14 @@ import ArgumentParser import Foundation -internal struct Version: ParsableCommand { - public init() {} +struct Version: ParsableCommand { - public static let configuration: CommandConfiguration = .init( + static let configuration: CommandConfiguration = .init( commandName: "version", abstract: "Display the version information" ) - public func run() { + func run() { print("\(Main.versionString)") } }