Skip to content

Commit

Permalink
Add windowId and workspace properties to all CmdArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Sep 21, 2024
1 parent 75bd6cf commit c078a63
Show file tree
Hide file tree
Showing 35 changed files with 127 additions and 60 deletions.
2 changes: 2 additions & 0 deletions Sources/Common/cmdArgs/BalanceSizesCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ public struct BalanceSizesCmdArgs: RawCmdArgs, CmdArgs {
public let rawArgs: EquatableNoop<[String]>
public init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = noArgsParser(.balanceSizes, allowInConfig: true)
public var windowId: UInt32?
public var workspaceName: String?
}
2 changes: 2 additions & 0 deletions Sources/Common/cmdArgs/CloseAllWindowsButCurrentCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public struct CloseAllWindowsButCurrentCmdArgs: RawCmdArgs, CmdArgs {
)

public var closeArgs = CloseCmdArgs(rawArgs: [])
public var windowId: UInt32?
public var workspaceName: String?
}

public func parseCloseAllWindowsButCurrentCmdArgs(_ args: [String]) -> ParsedCmd<CloseAllWindowsButCurrentCmdArgs> {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Common/cmdArgs/CloseCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public struct CloseCmdArgs: RawCmdArgs, CmdArgs {
)

public var quitIfLastWindow: Bool = false
public var windowId: UInt32?
public var workspaceName: String?
}
7 changes: 4 additions & 3 deletions Sources/Common/cmdArgs/EnableCmdArgs.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
public struct EnableCmdArgs: RawCmdArgs {
public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = cmdParser(
kind: .enable,
allowInConfig: true,
Expand All @@ -16,12 +18,11 @@ public struct EnableCmdArgs: RawCmdArgs {
],
arguments: [newArgParser(\.targetState, parseState, mandatoryArgPlaceholder: EnableCmdArgs.State.unionLiteral)]
)
public var windowId: UInt32?
public var workspaceName: String?
public var targetState: Lateinit<State> = .uninitialized
public var failIfNoop: Bool = false

public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }

public init(rawArgs: [String], targetState: State) {
self.rawArgs = .init(rawArgs)
self.targetState = .initialized(targetState)
Expand Down
7 changes: 5 additions & 2 deletions Sources/Common/cmdArgs/ExecAndForgetCmdArgs.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
public struct ExecAndForgetCmdArgs: CmdArgs {
public let bashScript: String
public var rawArgs: EquatableNoop<[String]> { .init([bashScript]) }
public static let info: CmdStaticInfo = CmdStaticInfo(
help: "USAGE: exec-and-forget <bash-script>",
kind: .execAndForget,
allowInConfig: true
)

public var rawArgs: EquatableNoop<[String]> { .init([bashScript]) }
public init(bashScript: String) {
self.bashScript = bashScript
}

public let bashScript: String
public var windowId: UInt32?
public var workspaceName: String?
}
3 changes: 3 additions & 0 deletions Sources/Common/cmdArgs/FlattenWorkspaceTreeCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ public struct FlattenWorkspaceTreeCmdArgs: RawCmdArgs, CmdArgs {
public let rawArgs: EquatableNoop<[String]>
public init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = noArgsParser(.flattenWorkspaceTree, allowInConfig: true)

public var windowId: UInt32?
public var workspaceName: String?
}
3 changes: 3 additions & 0 deletions Sources/Common/cmdArgs/FocusBackAndForthCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ public struct FocusBackAndForthCmdArgs: RawCmdArgs, CmdArgs {
public let rawArgs: EquatableNoop<[String]>
public init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = noArgsParser(.focusBackAndForth, allowInConfig: true)

public var windowId: UInt32?
public var workspaceName: String?
}
8 changes: 4 additions & 4 deletions Sources/Common/cmdArgs/FocusCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ private let boundar = "<boundary>"
private let actio = "<action>"

public struct FocusCmdArgs: CmdArgs, RawCmdArgs, Equatable, AeroAny {
public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = cmdParser(
kind: .focus,
allowInConfig: true,
Expand Down Expand Up @@ -37,13 +39,11 @@ public struct FocusCmdArgs: CmdArgs, RawCmdArgs, Equatable, AeroAny {

public var rawBoundaries: Boundaries? = nil // todo cover boundaries wrapping with tests
public var rawBoundariesAction: WhenBoundariesCrossed? = nil
public var windowId: UInt32? = nil
public var dfsIndex: UInt32? = nil
public var direction: CardinalDirection? = nil
public var floatingAsTiling: Bool = true

public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public var windowId: UInt32?
public var workspaceName: String?

public init(rawArgs: [String], direction: CardinalDirection) {
self.rawArgs = .init(rawArgs)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Common/cmdArgs/FocusMonitorCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public struct FocusMonitorCmdArgs: RawCmdArgs, CmdArgs {

public var wrapAround: Bool = false
public var target: Lateinit<MonitorTarget> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?
}

public func parseFocusMonitorCmdArgs(_ args: [String]) -> ParsedCmd<FocusMonitorCmdArgs> {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Common/cmdArgs/FullscreenCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public struct FullscreenCmdArgs: CmdArgs, RawCmdArgs {
public var toggle: ToggleEnum = .toggle
public var noOuterGaps: Bool = false
public var failIfNoop: Bool = false
public var windowId: UInt32?
public var workspaceName: String?
}

public func parseFullscreenCmdArgs(_ args: [String]) -> ParsedCmd<FullscreenCmdArgs> {
Expand Down
8 changes: 5 additions & 3 deletions Sources/Common/cmdArgs/JoinWithCmdArgs.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
public struct JoinWithCmdArgs: CmdArgs, RawCmdArgs {
public let rawArgs: EquatableNoop<[String]>
init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = cmdParser(
kind: .joinWith,
allowInConfig: true,
Expand All @@ -11,10 +13,10 @@ public struct JoinWithCmdArgs: CmdArgs, RawCmdArgs {
options: [:],
arguments: [newArgParser(\.direction, parseCardinalDirectionArg, mandatoryArgPlaceholder: CardinalDirection.unionLiteral)]
)
public var direction: Lateinit<CardinalDirection> = .uninitialized

public let rawArgs: EquatableNoop<[String]>
init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public var direction: Lateinit<CardinalDirection> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?

public init(rawArgs: [String], direction: CardinalDirection) {
self.rawArgs = .init(rawArgs)
Expand Down
8 changes: 5 additions & 3 deletions Sources/Common/cmdArgs/LayoutCmdArgs.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
public struct LayoutCmdArgs: CmdArgs, RawCmdArgs, Equatable {
public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = cmdParser(
kind: .layout,
allowInConfig: true,
Expand All @@ -11,10 +13,10 @@ public struct LayoutCmdArgs: CmdArgs, RawCmdArgs, Equatable {
options: [:],
arguments: [newArgParser(\.toggleBetween, parseToggleBetween, mandatoryArgPlaceholder: LayoutDescription.unionLiteral)]
)
public var toggleBetween: Lateinit<[LayoutDescription]> = .uninitialized

public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public var toggleBetween: Lateinit<[LayoutDescription]> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?

public init(rawArgs: [String], toggleBetween: [LayoutDescription]) {
self.rawArgs = .init(rawArgs)
Expand Down
3 changes: 3 additions & 0 deletions Sources/Common/cmdArgs/ListExecEnvVarsCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ public struct ListExecEnvVarsCmdArgs: RawCmdArgs, CmdArgs {
public let rawArgs: EquatableNoop<[String]>
public init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = noArgsParser(.listExecEnvVars, allowInConfig: true)

public var windowId: UInt32?
public var workspaceName: String?
}
6 changes: 4 additions & 2 deletions Sources/Common/cmdArgs/MacosNativeFullscreen.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
public struct MacosNativeFullscreenCmdArgs: CmdArgs, RawCmdArgs {
public let rawArgs: EquatableNoop<[String]>
public var failIfNoop: Bool = false

public init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = cmdParser(
kind: .macosNativeFullscreen,
Expand All @@ -24,7 +22,11 @@ public struct MacosNativeFullscreenCmdArgs: CmdArgs, RawCmdArgs {
],
arguments: [ArgParser(\.toggle, parseToggleEnum)]
)

public var toggle: ToggleEnum = .toggle
public var failIfNoop: Bool = false
public var windowId: UInt32?
public var workspaceName: String?
}

public func parseMacosNativeFullscreenCmdArgs(_ args: [String]) -> ParsedCmd<MacosNativeFullscreenCmdArgs> {
Expand Down
3 changes: 3 additions & 0 deletions Sources/Common/cmdArgs/MacosNativeMinimize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ public struct MacosNativeMinimizeCmdArgs: RawCmdArgs, CmdArgs {
public let rawArgs: EquatableNoop<[String]>
public init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = noArgsParser(.macosNativeMinimize, allowInConfig: true)

public var windowId: UInt32?
public var workspaceName: String?
}
3 changes: 3 additions & 0 deletions Sources/Common/cmdArgs/ModeCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ public struct ModeCmdArgs: RawCmdArgs {
options: [:],
arguments: [newArgParser(\.targetMode, parseTargetMode, mandatoryArgPlaceholder: "<binding-mode>")]
)

public var targetMode: Lateinit<String> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?
}

private func parseTargetMode(arg: String, nextArgs: inout [String]) -> Parsed<String> {
Expand Down
8 changes: 5 additions & 3 deletions Sources/Common/cmdArgs/MoveCmdArgs.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
public struct MoveCmdArgs: CmdArgs, RawCmdArgs {
public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = cmdParser(
kind: .move,
allowInConfig: true,
Expand All @@ -11,10 +13,10 @@ public struct MoveCmdArgs: CmdArgs, RawCmdArgs {
options: [:],
arguments: [newArgParser(\.direction, parseCardinalDirectionArg, mandatoryArgPlaceholder: CardinalDirection.unionLiteral)]
)
public var direction: Lateinit<CardinalDirection> = .uninitialized

public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public var direction: Lateinit<CardinalDirection> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?

public init(rawArgs: [String], _ direction: CardinalDirection) {
self.rawArgs = .init(rawArgs)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Common/cmdArgs/MoveMouseCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public struct MoveMouseCmdArgs: CmdArgs, RawCmdArgs {

public var failIfNoop: Bool = false
public var mouseTarget: Lateinit<MouseTarget> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?
}

func parseMouseTarget(arg: String, nextArgs: inout [String]) -> Parsed<MouseTarget> {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Common/cmdArgs/MoveNodeToMonitorCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public struct MoveNodeToMonitorCmdArgs: RawCmdArgs, CmdArgs, Equatable {

public var wrapAround: Bool = false
public var target: Lateinit<MonitorTarget> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?
}

public func parseMoveNodeToMonitorCmdArgs(_ args: [String]) -> ParsedCmd<MoveNodeToMonitorCmdArgs> {
Expand Down
17 changes: 9 additions & 8 deletions Sources/Common/cmdArgs/MoveNodeToWorkspaceCmdArgs.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
public struct MoveNodeToWorkspaceCmdArgs: CmdArgs, RawCmdArgs {
public let rawArgs: EquatableNoop<[String]>
public var target: Lateinit<WorkspaceTarget> = .uninitialized

public var _wrapAround: Bool?
public var failIfNoop: Bool = false

public init(rawArgs: [String]) {
self.rawArgs = .init(rawArgs)
}

public static let parser: CmdParser<Self> = cmdParser(
kind: .moveNodeToWorkspace,
allowInConfig: true,
Expand All @@ -31,6 +23,15 @@ public struct MoveNodeToWorkspaceCmdArgs: CmdArgs, RawCmdArgs {
],
arguments: [newArgParser(\.target, parseWorkspaceTarget, mandatoryArgPlaceholder: workspaceTargetPlaceholder)]
)

public var _wrapAround: Bool?
public var failIfNoop: Bool = false
public var windowId: UInt32?
public var workspaceName: String?

public init(rawArgs: [String]) {
self.rawArgs = .init(rawArgs)
}
}

public extension MoveNodeToWorkspaceCmdArgs {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Common/cmdArgs/MoveWorkspaceToMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public struct MoveWorkspaceToMonitorCmdArgs: RawCmdArgs {
arguments: [newArgParser(\.target, parseMonitorTarget, mandatoryArgPlaceholder: "(next|prev)")]
)

public var windowId: UInt32?
public var workspaceName: String?
public var wrapAround: Bool = false
public var target: Lateinit<MoveWorkspaceToMonitorCmdArgs.MonitorTarget> = .uninitialized
public enum MonitorTarget: String, CaseIterable {
Expand Down
3 changes: 2 additions & 1 deletion Sources/Common/cmdArgs/ReloadConfigCmdArgs.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
public struct ReloadConfigCmdArgs: RawCmdArgs, CmdArgs {
public let rawArgs: EquatableNoop<[String]>
public init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }

public static let parser: CmdParser<Self> = cmdParser(
kind: .reloadConfig,
allowInConfig: true,
Expand All @@ -22,4 +21,6 @@ public struct ReloadConfigCmdArgs: RawCmdArgs, CmdArgs {

public var noGui: Bool = false
public var dryRun: Bool = false
public var windowId: UInt32?
public var workspaceName: String?
}
7 changes: 4 additions & 3 deletions Sources/Common/cmdArgs/ResizeCmdArgs.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
public struct ResizeCmdArgs: RawCmdArgs, Equatable {
public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = cmdParser(
kind: .resize,
allowInConfig: true,
Expand All @@ -21,8 +23,9 @@ public struct ResizeCmdArgs: RawCmdArgs, Equatable {

public var dimension: Lateinit<ResizeCmdArgs.Dimension> = .uninitialized
public var units: Lateinit<ResizeCmdArgs.Units> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?

public let rawArgs: EquatableNoop<[String]>
public init(
rawArgs: [String],
dimension: Dimension,
Expand All @@ -33,8 +36,6 @@ public struct ResizeCmdArgs: RawCmdArgs, Equatable {
self.units = .initialized(units)
}

fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }

public enum Dimension: String, CaseIterable, Equatable {
case width, height, smart
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ public struct ServerVersionInternalCommandCmdArgs: RawCmdArgs, CmdArgs {
public let rawArgs: EquatableNoop<[String]>
public init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = noArgsParser(.serverVersionInternalCommand, allowInConfig: false)

public var windowId: UInt32?
public var workspaceName: String?
}
8 changes: 5 additions & 3 deletions Sources/Common/cmdArgs/SplitCmdArgs.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
public struct SplitCmdArgs: RawCmdArgs {
public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = cmdParser(
kind: .split,
allowInConfig: true,
Expand All @@ -11,10 +13,10 @@ public struct SplitCmdArgs: RawCmdArgs {
options: [:],
arguments: [newArgParser(\.arg, parseSplitArg, mandatoryArgPlaceholder: SplitArg.unionLiteral)]
)
public var arg: Lateinit<SplitArg> = .uninitialized

public let rawArgs: EquatableNoop<[String]>
fileprivate init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public var arg: Lateinit<SplitArg> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?

public init(rawArgs: [String], _ arg: SplitArg) {
self.rawArgs = .init(rawArgs)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Common/cmdArgs/TriggerBindingCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public struct TriggerBindingCmdArgs: RawCmdArgs, CmdArgs {

public var _mode: String? = nil
public var binding: Lateinit<String> = .uninitialized
public var windowId: UInt32?
public var workspaceName: String?
}

public extension TriggerBindingCmdArgs {
Expand Down
3 changes: 3 additions & 0 deletions Sources/Common/cmdArgs/WorkspaceBackAndForthCmdArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ public struct WorkspaceBackAndForthCmdArgs: RawCmdArgs, CmdArgs {
public let rawArgs: EquatableNoop<[String]>
public init(rawArgs: [String]) { self.rawArgs = .init(rawArgs) }
public static let parser: CmdParser<Self> = noArgsParser(.workspaceBackAndForth, allowInConfig: true)

public var windowId: UInt32?
public var workspaceName: String?
}
Loading

0 comments on commit c078a63

Please sign in to comment.