Support "tart --version" (#81)

* Support "tart --version"

* Move CI.swift patcher into a separate script

Otherwise it doesn't work in GoReleaser.
This commit is contained in:
Nikolay Edigaryev
2022-05-17 10:40:21 -04:00
committed by GitHub
parent 63a2793c32
commit c2da3fd919
5 changed files with 33 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
cat Sources/tart/CI/CI.swift | envsubst | tee Sources/tart/CI/CI.swift
+1
View File
@@ -11,6 +11,7 @@ builds:
before:
hooks:
- .ci/set-version.sh
- swift build -c release --product tart
- codesign --sign - --entitlements Resources/tart.entitlements --force .build/arm64-apple-macosx/release/tart
+13
View File
@@ -0,0 +1,13 @@
struct CI {
private static let rawVersion = "${CIRRUS_TAG}"
static var version: String {
rawVersion.expanded() ? rawVersion : "SNAPSHOT"
}
}
private extension String {
func expanded() -> Bool {
!isEmpty && !starts(with: "$")
}
}
+15
View File
@@ -62,6 +62,8 @@ struct Run: AsyncParsableCommand {
CommandGroup(replacing: .textEditing, addition: {})
CommandGroup(replacing: .undoRedo, addition: {})
CommandGroup(replacing: .windowSize, addition: {})
// Replace some standard menu options
CommandGroup(replacing: .appInfo) { AboutTart() }
}
}
}
@@ -70,6 +72,19 @@ struct Run: AsyncParsableCommand {
}
}
struct AboutTart: View {
var body: some View {
Button("About Tart") {
NSApplication.shared.orderFrontStandardAboutPanel(options: [
NSApplication.AboutPanelOptionKey.applicationIcon: NSApplication.shared.applicationIconImage as Any,
NSApplication.AboutPanelOptionKey.applicationName: "Tart",
NSApplication.AboutPanelOptionKey.applicationVersion: CI.version,
NSApplication.AboutPanelOptionKey.credits: try! NSAttributedString(markdown: "https://github.com/cirruslabs/tart"),
])
}
}
}
struct VMView: NSViewRepresentable {
typealias NSViewType = VZVirtualMachineView
+1
View File
@@ -5,6 +5,7 @@ import Foundation
struct Root: AsyncParsableCommand {
static var configuration = CommandConfiguration(
commandName: "tart",
version: CI.version,
subcommands: [
Create.self,
Clone.self,