Skip to content

Commit

Permalink
Adds --version
Browse files Browse the repository at this point in the history
  • Loading branch information
xenodium committed Apr 16, 2023
1 parent 26e3af8 commit 89cf4cf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sources/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import AVFoundation
import ArgumentParser
import Cocoa

let packageVersion = "0.2.1"

var recorder: WindowRecorder?

signal(SIGINT) { _ in
Expand All @@ -33,6 +35,9 @@ signal(SIGTERM) { _ in
}

struct RecordCommand: ParsableCommand {
@Flag(name: [.customLong("version")], help: "Show version.")
var showVersion: Bool = false

@Flag(name: .shortAndLong, help: "List recordable windows.")
var list: Bool = false

Expand Down Expand Up @@ -67,6 +72,15 @@ struct RecordCommand: ParsableCommand {
var output: String?

mutating func run() throws {
if showVersion {
guard let binPath = CommandLine.arguments.first else {
print("Error: binary name not available")
Darwin.exit(1)
}
print("\(URL(fileURLWithPath: binPath).lastPathComponent) \(packageVersion)")
Darwin.exit(0)
}

if list {
NSWorkspace.shared.printWindowList()
Darwin.exit(0)
Expand Down

0 comments on commit 89cf4cf

Please sign in to comment.