mirror of
https://github.com/apple/container.git
synced 2026-09-21 07:05:57 +00:00
@@ -23,6 +23,7 @@ import Containerization
|
||||
import ContainerizationError
|
||||
import ContainerizationOCI
|
||||
import Foundation
|
||||
import SystemPackage
|
||||
import TerminalProgress
|
||||
|
||||
extension Application {
|
||||
@@ -47,9 +48,13 @@ extension Application {
|
||||
@Option(
|
||||
name: .shortAndLong, help: "Pathname for the saved image", completion: .file(),
|
||||
transform: { str in
|
||||
URL(fileURLWithPath: str, relativeTo: .currentDirectory()).absoluteURL.path(percentEncoded: false)
|
||||
let path = FilePath(str)
|
||||
guard path.isRelative else { return path.lexicallyNormalized() }
|
||||
return FilePath(FileManager.default.currentDirectoryPath)
|
||||
.pushing(path)
|
||||
.lexicallyNormalized()
|
||||
})
|
||||
var output: String?
|
||||
var output: FilePath?
|
||||
|
||||
@Option(
|
||||
help: "Platform for the saved image (format: os/arch[/variant], takes precedence over --os and --arch) [environment: CONTAINER_DEFAULT_PLATFORM]"
|
||||
@@ -109,7 +114,9 @@ extension Application {
|
||||
}
|
||||
|
||||
// Write to stdout; otherwise write to the output file
|
||||
if output == nil {
|
||||
if let output {
|
||||
try await ClientImage.save(references: references, out: output.string, platform: p, containerSystemConfig: containerSystemConfig)
|
||||
} else {
|
||||
let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent("\(UUID().uuidString).tar")
|
||||
defer {
|
||||
try? FileManager.default.removeItem(at: tempFile)
|
||||
@@ -132,8 +139,6 @@ extension Application {
|
||||
FileHandle.standardOutput.write(chunk)
|
||||
}
|
||||
try fileHandle.close()
|
||||
} else {
|
||||
try await ClientImage.save(references: references, out: output!, platform: p, containerSystemConfig: containerSystemConfig)
|
||||
}
|
||||
|
||||
progress.finish()
|
||||
|
||||
Reference in New Issue
Block a user