Skip to content

Commit 189efe9

Browse files
committed
feat: add a cli task
1 parent 5f176ad commit 189efe9

6 files changed

Lines changed: 144 additions & 3 deletions

File tree

.claude/agents/swift-macos-engineer.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ color: purple
77

88
You are an elite Swift macOS software engineer with 10+ years of experience building production macOS applications. You possess deep expertise in Swift, SwiftUI, AppKit, Cocoa frameworks, and macOS system integration.
99

10+
Before writing code, **ALWAYS** propose a plan and ask for confirmation, you are not allowed to write code without a plan. Do not propose plan in weekly or monthly format, just propose a plan for the next task.
11+
1012
Your core competencies include:
1113

1214
- Modern Swift patterns, protocols, generics, and async/await

.github/copilot-instructions.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,50 @@ All shell scripts must follow these patterns:
7171
- Use `${variable}` syntax with braces (never `$variable`)
7272
- Use `local` for function variables to avoid namespace pollution
7373
- Pass `shellcheck` validation before committing
74+
- When implementing commands, when things exist, do not use `else` branches unless necessary, for example:
75+
76+
Prefer to do this:
77+
78+
```bash
79+
#!/usr/bin/env bash
80+
if ! tart list | grep -q "sparkdock-test"; then
81+
tart clone {{IMAGE}} sparkdock-test
82+
echo "✅ VM 'sparkdock-test' created successfully"
83+
fi
84+
```
85+
Instead of this:
86+
87+
Do not do this:
88+
89+
```bash
90+
#!/usr/bin/env bash
91+
if ! tart list | grep -q "sparkdock-test"; then
92+
tart clone {{IMAGE}} sparkdock-test
93+
echo "✅ VM 'sparkdock-test' created successfully"
94+
else
95+
echo "VM 'sparkdock-test' already exists"
96+
fi
97+
````
98+
99+
Instead of this:
100+
101+
```bash
102+
if ! command -v cirrus >/dev/null 2>&1; then
103+
echo "Installing Cirrus CLI via Homebrew..."
104+
brew install cirruslabs/cli/cirrus
105+
else
106+
echo "Cirrus CLI is already installed"
107+
fi
108+
```
109+
110+
Do this:
111+
112+
```bash
113+
if ! command -v cirrus >/dev/null 2>&1; then
114+
echo "Installing Cirrus CLI via Homebrew..."
115+
brew install cirruslabs/cli/cirrus
116+
fi
117+
```
74118

75119
**Critical: No Trailing Whitespace**
76120

.github/prompts/swift-macos-engineer.prompt.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ description: "Elite Swift macOS engineer with access to latest Swift documentati
3535

3636
You are an elite Swift macOS software engineer. For comprehensive expertise and guidelines, reference: #file:../../.claude/agents/swift-macos-engineer.md
3737

38-
Before writing code, **ALWAYS** propose a plan and ask for confirmation, you are not allowed to write code without a plan. Do not propose plan in weekly or monthly format, just propose a plan for the next task.
39-
4038
## VS Code-Specific Enhancements
4139

4240
### Context7 Integration

Justfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
_default:
2+
@just --list
3+
14
run-ansible-macos TAGS="all":
25
#!/usr/bin/env bash
36
TAGS={{TAGS}}
@@ -6,3 +9,47 @@ run-ansible-macos TAGS="all":
69
else
710
ansible-playbook ./ansible/macos.yml -i ./ansible/inventory.ini --ask-become-pass --tags=${TAGS} -v
811
fi
12+
13+
# Create macOS VM with Tart (installs Tart if needed)
14+
# Available VM images: https://tart.run/quick-start/#vm-images
15+
tart-create-vm IMAGE="ghcr.io/cirruslabs/macos-sequoia-base:latest":
16+
#!/usr/bin/env bash
17+
if ! command -v tart >/dev/null 2>&1; then
18+
echo "Installing Tart via Homebrew..."
19+
brew install cirruslabs/cli/tart
20+
fi
21+
echo "Creating macOS VM with Tart using image: {{IMAGE}}..."
22+
if ! tart list | grep -q "sparkdock-test"; then
23+
tart clone {{IMAGE}} sparkdock-test
24+
echo "✅ VM 'sparkdock-test' created successfully"
25+
fi
26+
27+
# Start VM and connect via SSH
28+
tart-ssh: tart-create-vm
29+
#!/usr/bin/env bash
30+
echo "Starting VM and connecting via SSH..."
31+
echo "Note: This will start the VM in the background and connect via SSH"
32+
echo "VM credentials: admin/admin"
33+
echo "Sparkdock source will be mounted at /opt/sparkdock-src"
34+
tart run --dir=sparkdock-src:$PWD sparkdock-test &
35+
echo "Waiting for VM to boot..."
36+
sleep 30
37+
VM_IP=$(tart ip sparkdock-test 2>/dev/null || echo "")
38+
if [ -n "$VM_IP" ]; then
39+
echo "Connecting to VM at $VM_IP..."
40+
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null admin@$VM_IP
41+
else
42+
echo "❌ Could not get VM IP address. Make sure the VM is running."
43+
echo "You can manually check with: tart list"
44+
exit 1
45+
fi
46+
47+
# Run end-to-end sparkdock test using Cirrus CLI
48+
test-e2e-with-cirrus:
49+
#!/usr/bin/env bash
50+
if ! command -v cirrus >/dev/null 2>&1; then
51+
echo "Installing Cirrus CLI via Homebrew..."
52+
brew install cirruslabs/cli/cirrus
53+
fi
54+
echo "Running sparkdock end-to-end test with Cirrus CLI..."
55+
cirrus run --output simple

ansible/macos/macos/base.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,15 @@
395395
become: yes
396396
become_method: sudo
397397

398+
- name: Verify menu bar app works
399+
command: /usr/local/bin/sparkdock-manager --status
400+
register: sparkdock_status
401+
changed_when: false
402+
403+
- name: Display menu bar app status
404+
debug:
405+
msg: "{{ sparkdock_status.stdout_lines }}"
406+
398407
- name: Check CI environment
399408
debug:
400409
msg:

src/menubar-app/Sources/SparkdockManager/main.swift

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,49 @@ class SparkdockMenubarApp: NSObject, NSApplicationDelegate {
463463
}
464464
}
465465

466+
// MARK: - CLI Handling
467+
private func handleCLIArguments() -> Bool {
468+
let arguments = CommandLine.arguments
469+
470+
if arguments.contains("--help") || arguments.contains("-h") {
471+
print("""
472+
Sparkdock Manager - macOS menu bar application for development environment management
473+
474+
Usage: sparkdock-manager [options]
475+
476+
Options:
477+
--help, -h Show this help message
478+
--status Show application status
479+
480+
When run without arguments, launches as a menu bar application.
481+
""")
482+
return true
483+
}
484+
485+
if arguments.contains("--status") {
486+
print("Sparkdock Manager - Status: OK")
487+
print("Executable path: /opt/sparkdock/bin/sparkdock.macos")
488+
print("Config file: Sources/SparkdockManager/Resources/menu.json")
489+
490+
// Check if sparkdock executable exists
491+
if FileManager.default.fileExists(atPath: AppConstants.sparkdockExecutablePath) {
492+
print("Sparkdock executable: ✅ Found")
493+
} else {
494+
print("Sparkdock executable: ❌ Not found")
495+
}
496+
497+
return true
498+
}
499+
500+
return false
501+
}
502+
466503
// MARK: - Main Entry Point
504+
if handleCLIArguments() {
505+
exit(0)
506+
}
507+
467508
let app = NSApplication.shared
468509
let delegate = SparkdockMenubarApp()
469510
app.delegate = delegate
470-
app.run()
511+
app.run()

0 commit comments

Comments
 (0)