Skip to content

Commit ae8558e

Browse files
committed
Implement debug-windows command
closes #137
1 parent dce42f1 commit ae8558e

14 files changed

Lines changed: 219 additions & 6 deletions

AeroSpace.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
43E3628E37D2439B820FFC82 /* server.swift in Sources */ = {isa = PBXBuildFile; fileRef = 796713A1B3AEEBF4D0D180C7 /* server.swift */; };
3333
45AA5FD4A023AF751922BC22 /* BundleEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B7A2DF0D1F72B80B1F04240 /* BundleEx.swift */; };
3434
45EA2D1C90430C432E123B51 /* keysMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C0D40CBD65704BA9595C2FA /* keysMap.swift */; };
35+
4CC374136F60299FB672662D /* DebugWindowsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71908440CD1ADBE13AD58E26 /* DebugWindowsCommand.swift */; };
3536
51AB4C0992703B2E9D0F55E2 /* MonitorDescriptionEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C1D626244E63437F1CA24C3 /* MonitorDescriptionEx.swift */; };
3637
56E72B24303F5F337B31B776 /* TrayMenuModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F5F52E346D024960EAF5938 /* TrayMenuModel.swift */; };
3738
5BA537EABFE48178D6BD2544 /* parseGaps.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCDFB9D7321F08B5CCEF6AFB /* parseGaps.swift */; };
@@ -149,6 +150,7 @@
149150
67DBAF4ECF8A0B931FC34EAD /* parseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = parseConfig.swift; sourceTree = "<group>"; };
150151
6D9C5ED5AC77D80F1CCD103F /* JoinWithCommandTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinWithCommandTest.swift; sourceTree = "<group>"; };
151152
6F1905935B0C61590A96EFEF /* TestWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestWindow.swift; sourceTree = "<group>"; };
153+
71908440CD1ADBE13AD58E26 /* DebugWindowsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugWindowsCommand.swift; sourceTree = "<group>"; };
152154
739F4FE1DB101DF4E508F3FE /* Monitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Monitor.swift; sourceTree = "<group>"; };
153155
796713A1B3AEEBF4D0D180C7 /* server.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = server.swift; sourceTree = "<group>"; };
154156
7ACD4E9C6C0C08F1B0622C57 /* ResizeCommandTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResizeCommandTest.swift; sourceTree = "<group>"; };
@@ -387,6 +389,7 @@
387389
9797FA095A9BE84428C5E2C0 /* query */ = {
388390
isa = PBXGroup;
389391
children = (
392+
71908440CD1ADBE13AD58E26 /* DebugWindowsCommand.swift */,
390393
B0185502A3752FF618BB3D36 /* ListAppsCommand.swift */,
391394
FD6BB613EC44C1B32CE4A47E /* ListMonitorsCommand.swift */,
392395
E9FCB66B928701F68AD8CA78 /* ListWindowsCommand.swift */,
@@ -599,6 +602,7 @@
599602
78C38FAF21E574DBE3B88806 /* CloseCommand.swift in Sources */,
600603
F982DB924450BBBB4FDF4C2C /* Command.swift in Sources */,
601604
FD4386BC632BAA6A4105FFD8 /* Config.swift in Sources */,
605+
4CC374136F60299FB672662D /* DebugWindowsCommand.swift in Sources */,
602606
B0D7495387478CE6FBE79A2E /* DynamicConfigValue.swift in Sources */,
603607
9FAD09BC5CC390167106563B /* EnableCommand.swift in Sources */,
604608
BC6511DA2ABE84164D90C181 /* ExecAndForgetCommand.swift in Sources */,

LocalPackage/Sources/Cli/subcommandDescriptionsGenerated.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
let subcommandDescriptions = [
33
[" close-all-windows-but-current", "On the focused workspace, closes all windows but current"],
44
[" close", "Closes the focused window"],
5+
[" debug-windows", "Interactive command to record Accessibility API debug information to create bug reports"],
56
[" enable", "Temporarily disable window management"],
67
[" flatten-workspace-tree", "Flattens the tree of currently focused workspace."],
78
[" focus", "Sets focus to the nearest window in in the given direction."],

LocalPackage/Sources/Common/cmdArgs/CmdKind.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
public enum CmdKind: String, CaseIterable, Equatable {
22
case close
33
case closeAllWindowsButCurrent = "close-all-windows-but-current"
4+
case debugWindows = "debug-windows"
45
case enable
56
case execAndForget = "exec-and-forget"
67
case flattenWorkspaceTree = "flatten-workspace-tree"

LocalPackage/Sources/Common/cmdArgs/noCmdArgs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public struct ServerVersionInternalCommandCmdArgs: RawCmdArgs, CmdArgs {
3131
public static let parser: CmdParser<Self> = noArgsParser(.serverVersionInternalCommand, allowInConfig: false)
3232
}
3333

34-
private func noArgsParser<T : Copyable>(_ kind: CmdKind, allowInConfig: Bool) -> CmdParser<T> {
34+
func noArgsParser<T : Copyable>(_ kind: CmdKind, allowInConfig: Bool) -> CmdParser<T> {
3535
cmdParser(
3636
kind: kind,
3737
allowInConfig: allowInConfig,

LocalPackage/Sources/Common/cmdArgs/parseCmdArgs.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ private func initSubcommands() -> [String: any SubCommandParserProtocol] {
2222
result[kind.rawValue] = noArgsSubCommandParser(CloseCmdArgs())
2323
case .closeAllWindowsButCurrent:
2424
result[kind.rawValue] = noArgsSubCommandParser(CloseAllWindowsButCurrentCmdArgs())
25+
case .debugWindows:
26+
result[kind.rawValue] = noArgsSubCommandParser(DebugWindowsCmdArgs())
2527
case .enable:
2628
result[kind.rawValue] = SubCommandParser(parseEnableCmdArgs)
2729
case .execAndForget:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public struct DebugWindowsCmdArgs: RawCmdArgs, CmdArgs {
2+
public init() {}
3+
public static let parser: CmdParser<Self> = noArgsParser(.debugWindows, allowInConfig: false)
4+
}

LocalPackage/Sources/Common/util/commonUtil.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public extension String {
9393
func removePrefix(_ prefix: String) -> String {
9494
hasPrefix(prefix) ? String(dropFirst(prefix.count)) : self
9595
}
96+
97+
func prependLines(_ prefix: String) -> String {
98+
split(separator: "\n").map { prefix + $0 }.joined(separator: "\n")
99+
}
96100
}
97101

98102
public extension Double {

docs/aerospace-debug-windows.adoc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
= aerospace-debug-windows(1)
2+
include::util/man-attributes.adoc[]
3+
:manname: aerospace-debug-windows
4+
// tag::purpose[]
5+
:manpurpose: Interactive command to record Accessibility API debug information to create bug reports
6+
// end::purpose[]
7+
8+
== Synopsis
9+
[verse]
10+
// tag::synopsis[]
11+
debug-windows [-h|--help]
12+
13+
// end::synopsis[]
14+
15+
== Description
16+
17+
// tag::body[]
18+
{manpurpose}
19+
20+
Use this command output to report bug reports about incorrect windows handling
21+
(e.g. some windows are floated when they shouldn't).
22+
23+
The intended usage is the following:
24+
25+
. Run the command to start the debug session recording
26+
. Focus problematic window
27+
. Run the command one more time to stop the debug session recording and print the results
28+
29+
_debug-windows_ command is *not stable API*.
30+
Please *don't rely on* the command existence and output format.
31+
The only intended use case is to report bugs about incorrect windows handling.
32+
33+
include::util/conditional-options-header.adoc[]
34+
35+
-h, --help:: Print help
36+
37+
// end::body[]
38+
39+
include::util/man-footer.adoc[]

docs/commands.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ Query commands are commands that do not change the state but rather allow the ex
168168
(because there is no way to consume the stdout of these commands in config)
169169
- Query commands are only available in CLI
170170

171+
=== debug-windows
172+
----
173+
include::aerospace-debug-windows.adoc[tags=synopsis]
174+
----
175+
include::aerospace-debug-windows.adoc[tags=purpose]
176+
include::aerospace-debug-windows.adoc[tags=body]
177+
171178
=== list-apps
172179
----
173180
include::aerospace-list-apps.adoc[tags=synopsis]

src/command/parseCommand.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ extension CmdArgs {
1313
command = CloseCommand()
1414
case .closeAllWindowsButCurrent:
1515
command = CloseAllWindowsButCurrentCommand()
16+
case .debugWindows:
17+
command = DebugWindowsCommand()
1618
case .enable:
1719
command = EnableCommand(args: self as! EnableCmdArgs)
1820
case .execAndForget:

0 commit comments

Comments
 (0)