Skip to content

Commit a77d33a

Browse files
committed
Squashed commit of the following:
commit dd6bdc2 Author: Morris Richman <81453549+Mcrich23@users.noreply.github.com> Date: Wed Sep 17 15:24:26 2025 -0700 Expose Command Structs for Plugins (apple#603) ## Type of Change - [ ] Bug fix - [x] New feature - [ ] Breaking change - [ ] Documentation update ## Motivation and Context Plugins technically exist, but to add shortcuts or to do existing things with functions in `container` requires calling a compiled binary. This pull request aims to remove that hurdle and instability by exposing commands as a new `ContainerCommands ` target. Simply import `ContainerCommands` and you can access almost any command as if it were a native part of the binary. This makes plugin development significantly easier. Closes apple#609.
1 parent d423d41 commit a77d33a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//===----------------------------------------------------------------------===//
2+
// Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//===----------------------------------------------------------------------===//
16+
17+
import ArgumentParser
18+
import ContainerClient
19+
import ContainerCommands
20+
21+
@main
22+
public struct Executable: AsyncParsableCommand {
23+
public init() {}
24+
25+
@Argument(parsing: .captureForPassthrough)
26+
var arguments: [String] = []
27+
28+
public static let configuration = Application.configuration
29+
30+
public static func main() async throws {
31+
try await Application.main()
32+
}
33+
34+
public func run() async throws {
35+
var application = try Application.parse(arguments)
36+
try application.validate()
37+
try application.run()
38+
}
39+
}

0 commit comments

Comments
 (0)