Skip to content

Commit 89cf4cf

Browse files
author
xenodium
committed
Adds --version
1 parent 26e3af8 commit 89cf4cf

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Sources/main.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import AVFoundation
2121
import ArgumentParser
2222
import Cocoa
2323

24+
let packageVersion = "0.2.1"
25+
2426
var recorder: WindowRecorder?
2527

2628
signal(SIGINT) { _ in
@@ -33,6 +35,9 @@ signal(SIGTERM) { _ in
3335
}
3436

3537
struct RecordCommand: ParsableCommand {
38+
@Flag(name: [.customLong("version")], help: "Show version.")
39+
var showVersion: Bool = false
40+
3641
@Flag(name: .shortAndLong, help: "List recordable windows.")
3742
var list: Bool = false
3843

@@ -67,6 +72,15 @@ struct RecordCommand: ParsableCommand {
6772
var output: String?
6873

6974
mutating func run() throws {
75+
if showVersion {
76+
guard let binPath = CommandLine.arguments.first else {
77+
print("Error: binary name not available")
78+
Darwin.exit(1)
79+
}
80+
print("\(URL(fileURLWithPath: binPath).lastPathComponent) \(packageVersion)")
81+
Darwin.exit(0)
82+
}
83+
7084
if list {
7185
NSWorkspace.shared.printWindowList()
7286
Darwin.exit(0)

0 commit comments

Comments
 (0)