Skip to content

Commit

Permalink
Rename app-id to app-bundle-id (preserving backwards compatibility)
Browse files Browse the repository at this point in the history
It's a more detailed name. %{app-id} wasn't yet released, so it's fine
to rename it. `--app-id` remains supported in `list-windows`

The biggest usage of "app-id" term is going to be renamed in
`on-window-detected` callback with the introduction of shell-like
combinators #278
  • Loading branch information
nikitabobko committed Jun 15, 2024
1 parent fdc143c commit d8c1ebf
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Sources/AppBundle/command/query/DebugWindowsCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func debugWindowsIfRecording(_ window: Window) {
return
}
let app = window.app as! MacApp
let appId = app.id ?? "null-app-id"
let appId = app.id ?? "NULL-APP-BUNDLE-ID"
let windowPrefix = appId + ".window.\(window.windowId)"
var result: [String] = []

Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundle/command/query/ListAppsCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct ListAppsCommand: Command {
state.stdout += result
.map { app in
let pid = String(app.pid)
let appId = app.id ?? "NULL-APP-ID"
let appId = app.id ?? "NULL-APP-BUNDLE-ID"
let name = app.name ?? "NULL-NAME"
return [pid, appId, name]
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundle/command/query/ListWindowsCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private extension String {
case "window-title": .success(window.title)
case "app-name": .success(window.app.name ?? "NULL-APP-NAME")
case "app-pid": .success(window.app.pid.description)
case "app-id": .success(window.app.id ?? "NULL-APP-ID")
case "app-bundle-id": .success(window.app.id ?? "NULL-APP-BUNDLE-ID")
case "workspace": .success(window.workspace?.name ?? "NULL-WOKRSPACE")
case "monitor-id": .success(window.nodeMonitor?.monitorId?.description ?? "NULL-MONITOR-ID")
case "monitor-name": .success(window.nodeMonitor?.name ?? "NULL-MONITOR-NAME")
Expand Down
23 changes: 12 additions & 11 deletions Sources/Common/cmdArgs/query/ListWindowsCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ public struct ListWindowsCmdArgs: RawCmdArgs, CmdArgs, Equatable {
help: """
USAGE: list-windows [-h|--help] (--workspace \(_workspaces)|--monitor \(_monitors))
[--monitor \(_monitors)] [--workspace \(_workspaces)]
[--pid <pid>] [--app-id <app-id>] [--format <output-format>]
[--pid <pid>] [--app-bundle-id <app-bundle-id>] [--format <output-format>]
OR: list-windows [-h|--help] --all [--format <output-format>]
OR: list-windows [-h|--help] --focused [--format <output-format>]
OPTIONS:
-h, --help Print help
--all Alias for "--monitor all"
--focused Print the focused window
--workspace \(_workspaces) Filter results to only print windows that belong to specified workspaces
--monitor \(_monitors) Filter results to only print the windows that are attached to specified monitors
--pid <pid> Filter results to only print windows that belong to the Application with specified <pid>
--app-id <app-id> Filter results to only print windows that belong to the Application with specified Bundle ID
--format <output-format> Specify output format
-h, --help Print help
--all Alias for "--monitor all"
--focused Print the focused window
--workspace \(_workspaces) Filter results to only print windows that belong to specified workspaces
--monitor \(_monitors) Filter results to only print the windows that are attached to specified monitors
--pid <pid> Filter results to only print windows that belong to the Application with specified <pid>
--app-bundle-id <app-bundle-id> Filter results to only print windows that belong to the Application with specified Bundle ID
--format <output-format> Specify output format
""",
options: [
"--focused": trueBoolFlag(\.focused),
Expand All @@ -32,7 +32,7 @@ public struct ListWindowsCmdArgs: RawCmdArgs, CmdArgs, Equatable {
"--monitor": ArgParser(\.monitors, parseMonitorIds),
"--workspace": ArgParser(\.workspaces, parseWorkspaces),
"--pid": singleValueOption(\.pidFilter, "<pid>", Int32.init),
"--app-id": singleValueOption(\.appIdFilter, "<app-id>", { $0 }),
"--app-bundle-id": singleValueOption(\.appIdFilter, "<app-bundle-id>", { $0 }),
"--format": ArgParser(\.format, parseFormat),
],
arguments: []
Expand All @@ -53,7 +53,8 @@ public struct ListWindowsCmdArgs: RawCmdArgs, CmdArgs, Equatable {
}

public func parseRawListWindowsCmdArgs(_ args: [String]) -> ParsedCmd<ListWindowsCmdArgs> {
parseRawCmdArgs(ListWindowsCmdArgs(rawArgs: .init(args)), args)
let args = args.map { $0 == "--app-id" ? "--app-bundle-id" : $0 } // Compatibility
return parseRawCmdArgs(ListWindowsCmdArgs(rawArgs: .init(args)), args)
.flatMap { raw in
var conflicting: OrderedSet<String> = []
if (raw.all) { conflicting.insert("--all", at: 0) }
Expand Down
4 changes: 2 additions & 2 deletions args-grammar.conf
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ aerospace <subcommand>;
<list-windows-filter-flag> ::= --workspace <workspace-or-special>...
| --monitor <monitor-id>...
| --pid <pid>
| --app-id <app-id>
| --app-bundle-id <app-bundle-id>
| <list-windows-format-flag>
;
<list-windows-format-flag> ::= --format <output-format>;
<output-format> ::= {{{ true }}};
<workspace-or-special> ::= visible | focused | <workspace>;
<app-id> ::= {{{ true }}}; # todo
<app-bundle-id> ::= {{{ true }}}; # todo
<pid> ::= {{{ true }}}; # todo
<monitor-id> ::= all | mouse | focused; # todo
9 changes: 6 additions & 3 deletions docs/aerospace-list-windows.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include::util/man-attributes.adoc[]
// tag::synopsis[]
aerospace list-windows [-h|--help] (--workspace <workspace>...|--monitor <monitor>...)
[--monitor <monitor>...] [--workspace <workspace>...]
[--pid <pid>] [--app-id <app-id>] [--format <output-format>]
[--pid <pid>] [--app-bundle-id <app-bundle-id>] [--format <output-format>]
aerospace list-windows [-h|--help] --all [--format <output-format>]
aerospace list-windows [-h|--help] --focused [--format <output-format>]

Expand Down Expand Up @@ -45,7 +45,10 @@ Possible values: +
include::util/monitor-option.adoc[]

--pid <pid>:: Filter results to only print windows that belong to the Application with specified `<pid>`
--app-id <app-id>:: Filter results to only print windows that belong to the Application with specified https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids[Bundle ID]
--app-bundle-id <app-bundle-id>::
Filter results to only print windows that belong to the Application with specified https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids[Bundle ID]
+
Deprecated (but still supported) flag name: `--app-id`
--format <output-format>::
Specify output format. See "Output Format" section for more details

Expand All @@ -63,7 +66,7 @@ The following variables can be used inside `<output-format>`:
%{window-title}:: String. Window title
%{app-name}:: String. Application name
%{app-pid}:: Number. https://en.wikipedia.org/wiki/Process_identifier[UNIX process identifier]
%{app-id}:: String. Application unique identifier. https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids[Bundle ID]
%{app-bundle-id}:: String. Application unique identifier. https://developer.apple.com/documentation/appstoreconnectapi/bundle_ids[Bundle ID]
%{workspace}:: String. Name of the belonging workspace
%{monitor-id}:: Number. Sequential number of the belonging monitor
%{monitor-name}:: String. Name of the belonging monitor
Expand Down

0 comments on commit d8c1ebf

Please sign in to comment.