From 50cdd9546b0753123433e286810dce8c29afdd8f Mon Sep 17 00:00:00 2001 From: Nikolay Edigaryev Date: Tue, 20 Feb 2024 01:02:06 +0400 Subject: [PATCH] Introduce "tart fqn" command --- Sources/tart/Commands/FQN.swift | 22 ++++++++++++++++++++++ Sources/tart/Root.swift | 1 + 2 files changed, 23 insertions(+) create mode 100644 Sources/tart/Commands/FQN.swift diff --git a/Sources/tart/Commands/FQN.swift b/Sources/tart/Commands/FQN.swift new file mode 100644 index 00000000..0fd7f060 --- /dev/null +++ b/Sources/tart/Commands/FQN.swift @@ -0,0 +1,22 @@ +import ArgumentParser +import Foundation +import SystemConfiguration + +struct FQN: AsyncParsableCommand { + static var configuration = CommandConfiguration(abstract: "Get a fully-qualified VM name", shouldDisplay: false) + + @Argument(help: "VM name") + var name: String + + func run() async throws { + if var remoteName = try? RemoteName(name) { + let digest = try VMStorageOCI().digest(remoteName) + + remoteName.reference = Reference(digest: digest) + + print(remoteName) + } else { + print(name) + } + } +} diff --git a/Sources/tart/Root.swift b/Sources/tart/Root.swift index e9345963..1be21f12 100644 --- a/Sources/tart/Root.swift +++ b/Sources/tart/Root.swift @@ -26,6 +26,7 @@ struct Root: AsyncParsableCommand { Rename.self, Stop.self, Delete.self, + FQN.self, ]) public static func main() async throws {