Skip to content

Commit 98f4e97

Browse files
dzanottonikitabobko
authored andcommitted
Add interpolation variables to --format flag
#592 closes #612
1 parent 0b8464f commit 98f4e97

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

Sources/AppBundle/command/format.swift

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ private enum FormatVar: Equatable {
6767
case appBundleId = "app-bundle-id"
6868
case appName = "app-name"
6969
case appPid = "app-pid"
70+
case appExecPath = "app-exec-path"
71+
case appBundlePath = "app-bundle-path"
7072
}
7173

7274
enum MonitorFormatVar: String, Equatable {
@@ -150,6 +152,8 @@ extension String {
150152
case .appBundleId: .success(.string(a.id ?? "NULL-APP-BUNDLE-ID"))
151153
case .appName: .success(.string(a.name ?? "NULL-APP-NAME"))
152154
case .appPid: .success(.int32(a.pid))
155+
case .appExecPath: .success(.string(a.execPath ?? "NULL-APP-EXEC-PATH"))
156+
case .appBundlePath: .success(.string(a.bundlePath ?? "NULL-APP-BUNDLE-PATH"))
153157
}
154158
default: break
155159
}

Sources/AppBundle/tree/AbstractApp.swift

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class AbstractApp: Hashable {
2525

2626
func getFocusedWindow(startup: Bool) -> Window? { error("Not implemented") }
2727
var name: String? { nil }
28+
var execPath: String? { nil }
29+
var bundlePath: String? { nil }
2830
func detectNewWindowsAndGetAll(startup: Bool) -> [Window] { error("Not implemented") }
2931
}
3032

Sources/AppBundle/tree/MacApp.swift

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ final class MacApp: AbstractApp {
5252

5353
override var name: String? { nsApp.localizedName }
5454

55+
override var execPath: String? { nsApp.executableURL?.path }
56+
57+
override var bundlePath: String? { nsApp.bundleURL?.path }
58+
5559
private func observe(_ handler: AXObserverCallback, _ notifKey: String) -> Bool {
5660
guard let observer = AXObserver.observe(nsApp.processIdentifier, notifKey, axApp, handler, data: nil) else { return false }
5761
axObservers.append(AxObserverWrapper(obs: observer, ax: axApp, notif: notifKey as CFString))

docs/aerospace-list-apps.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ The following variables can be used inside `<output-format>`:
5454
%{app-bundle-id}:: String. Application unique identifier. https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids[Bundle ID]
5555
%{app-name}:: String. Application name
5656
%{app-pid}:: Number. https://en.wikipedia.org/wiki/Process_identifier[UNIX process identifier]
57+
%{app-exec-path}:: String. Application executable path
58+
%{app-bundle-path}:: String. Application bundle path
5759

5860
%{right-padding}:: A special variable which expands with a minimum number of spaces required to form a right padding in the appropriate column
5961
%{newline}:: Unicode U+000A newline symbol `\n`

docs/aerospace-list-windows.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ The following variables can be used inside `<output-format>`:
8282
%{app-bundle-id}:: String. Application unique identifier. https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids[Bundle ID]
8383
%{app-name}:: String. Application name
8484
%{app-pid}:: Number. https://en.wikipedia.org/wiki/Process_identifier[UNIX process identifier]
85+
%{app-exec-path}:: String. Application executable path
86+
%{app-bundle-path}:: String. Application bundle path
8587

8688
%{workspace}:: String. Name of the belonging workspace
8789

0 commit comments

Comments
 (0)