From 3f17884ac2bdba56f5688537aa6da4d14533e3f4 Mon Sep 17 00:00:00 2001 From: Nikolay Edigaryev Date: Tue, 20 Feb 2024 01:13:45 +0400 Subject: [PATCH] Introduce "tart fqn" command (#735) * tart pull: experimental --json-digest option * Introduce "tart fqn" command * Revert "tart pull: experimental --json-digest option" This reverts commit 842052f5bdca8cf29cc4afd99bdb537f8d88b7cb. --- 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 {