Skip to content

Commit eec3f7b

Browse files
authored
feat: add option to hold shift when deleting simulators to skip alert (#137)
1 parent 26bb86f commit eec3f7b

5 files changed

Lines changed: 26 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ jobs:
2525
uses: norio-nomura/action-swiftlint@3.2.1
2626

2727
build:
28-
runs-on: macos-14
28+
runs-on: macos-latest
2929
steps:
3030
- name: Checkout Repository
3131
uses: actions/checkout@v2
3232
- name: Set up Xcode
3333
uses: maxim-lobanov/setup-xcode@v1
3434
with:
35-
xcode-version: 15
35+
xcode-version: 16
3636
- name: Cache DerivedData
37-
uses: actions/cache@v2
37+
uses: actions/cache@v4
3838
with:
3939
path: ${{ env.DERIVED_DATA_PATH }}
4040
key: ${{ runner.os }}-deriveddata-${{ hashFiles('**/*.xcodeproj/project.pbxproj') }}
@@ -50,16 +50,16 @@ jobs:
5050
5151
test:
5252
needs: build
53-
runs-on: macos-14
53+
runs-on: macos-latest
5454
steps:
5555
- name: Checkout Repository
5656
uses: actions/checkout@v2
5757
- name: Set up Xcode
5858
uses: maxim-lobanov/setup-xcode@v1
5959
with:
60-
xcode-version: 15
60+
xcode-version: 16
6161
- name: Cache DerivedData
62-
uses: actions/cache@v2
62+
uses: actions/cache@v4
6363
with:
6464
path: ${{ env.DERIVED_DATA_PATH }}
6565
key: ${{ runner.os }}-deriveddata-${{ hashFiles('**/*.xcodeproj/project.pbxproj') }}

MiniSim/Menu.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ class Menu: NSMenu {
9898
guard let tag = SubMenuItems.Tags(rawValue: sender.tag) else { return }
9999
guard let device = getDeviceByName(name: sender.parent?.title ?? "") else { return }
100100

101+
let skipConfirmation = NSEvent.modifierFlags.contains(.shift)
102+
101103
actionExecutor.execute(
102104
device: device,
103105
commandTag: tag,
104-
itemName: sender.title
106+
itemName: sender.title,
107+
skipConfirmation: skipConfirmation
105108
)
106109
}
107110

MiniSim/Service/ActionExecutor.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class ActionExecutor {
1111
func execute(
1212
device: Device,
1313
commandTag: SubMenuItems.Tags,
14-
itemName: String
14+
itemName: String,
15+
skipConfirmation: Bool = false
1516
) {
1617
let action: Action
1718

@@ -20,13 +21,15 @@ class ActionExecutor {
2021
action = AndroidActionFactory.createAction(
2122
for: commandTag,
2223
device: device,
23-
itemName: itemName
24+
itemName: itemName,
25+
skipConfirmation: skipConfirmation
2426
)
2527
case .ios:
2628
action = IOSActionFactory.createAction(
2729
for: commandTag,
2830
device: device,
29-
itemName: itemName
31+
itemName: itemName,
32+
skipConfirmation: skipConfirmation
3033
)
3134
}
3235

MiniSim/Service/ActionFactory.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import AppKit
22
import Foundation
33

44
protocol ActionFactory {
5-
static func createAction(for tag: SubMenuItems.Tags, device: Device, itemName: String) -> Action
5+
static func createAction(for tag: SubMenuItems.Tags, device: Device, itemName: String, skipConfirmation: Bool) -> Action
66
}
77

88
class AndroidActionFactory: ActionFactory {
9-
static func createAction(for tag: SubMenuItems.Tags, device: Device, itemName: String) -> any Action {
9+
static func createAction(for tag: SubMenuItems.Tags, device: Device, itemName: String, skipConfirmation: Bool = false) -> any Action {
1010
switch tag {
1111
case .copyName:
1212
return CopyNameAction(device: device)
@@ -21,7 +21,7 @@ class AndroidActionFactory: ActionFactory {
2121
case .paste:
2222
return PasteClipboardAction(device: device)
2323
case .delete:
24-
return DeleteAction(device: device)
24+
return DeleteAction(device: device, skipConfirmation: skipConfirmation)
2525
case .customCommand:
2626
return CustomCommandAction(device: device, itemName: itemName)
2727
case .logcat:
@@ -31,7 +31,7 @@ class AndroidActionFactory: ActionFactory {
3131
}
3232

3333
class IOSActionFactory: ActionFactory {
34-
static func createAction(for tag: SubMenuItems.Tags, device: Device, itemName: String) -> any Action {
34+
static func createAction(for tag: SubMenuItems.Tags, device: Device, itemName: String, skipConfirmation: Bool = false) -> any Action {
3535
switch tag {
3636
case .copyName:
3737
return CopyNameAction(device: device)
@@ -42,7 +42,7 @@ class IOSActionFactory: ActionFactory {
4242
case .coldBoot:
4343
return ColdBootCommand(device: device)
4444
case .delete:
45-
return DeleteAction(device: device)
45+
return DeleteAction(device: device, skipConfirmation: skipConfirmation)
4646
default:
4747
fatalError("Unhandled action tag: \(tag)")
4848
}

MiniSim/Service/Actions.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ class CopyNameAction: Action {
4444

4545
class DeleteAction: Action {
4646
let device: Device
47+
let skipConfirmation: Bool
4748

48-
init(device: Device) {
49+
init(device: Device, skipConfirmation: Bool = false) {
4950
self.device = device
51+
self.skipConfirmation = skipConfirmation
5052
}
5153

5254
func showQuestionDialog() -> Bool {
53-
!NSAlert.showQuestionDialog(
55+
guard !skipConfirmation else { return false }
56+
return !NSAlert.showQuestionDialog(
5457
title: "Are you sure?",
5558
message: "Are you sure you want to delete this device?"
5659
)

0 commit comments

Comments
 (0)