|
31 | 31 | - Emit logs through `log`/`oslog` with concise context fields so Console filtering remains effective. |
32 | 32 |
|
33 | 33 | ## Architecture & Design Patterns |
34 | | -- **Core components:** `main.rs` (Cocoa setup, initialization, run loop), `app.rs` (main state with `TunnelManager` and status item wrapper), `config.rs` (TOML config load/manage), `menu.rs` (NSStatusItem + NSMenu creation and icon handling), `tunnel.rs` (SSH/port-forward lifecycle), `logger.rs` (oslog configuration). |
35 | | -- **Key patterns:** thread-safe global state via `OnceLock<App>`, thread-safe Cocoa wrappers, Objective-C bridge class for menu callbacks, async threads for long-running tunnel commands. |
| 34 | +- **Core components:** `main.rs` (Cocoa setup, initialization, run loop), `app.rs` (main state with `TunnelManager`, `CommandRunner`, and status item wrapper), `config.rs` (TOML config load/manage, script auto-discovery), `command.rs` (one-time command execution with silent/notify/terminal output modes), `menu.rs` (NSStatusItem + NSMenu creation and icon handling), `tunnel.rs` (SSH/port-forward lifecycle), `logger.rs` (oslog configuration). |
| 35 | +- **Key patterns:** thread-safe global state via `OnceLock<App>`, thread-safe Cocoa wrappers, Objective-C bridge class for menu callbacks, async threads for long-running tunnel commands, callback-based cross-platform dispatch in `CommandRunner`. |
36 | 36 | - **Dependencies:** cocoa/objc2, core-foundation, log/oslog, libc, toml, serde; patched `objc` fork for compatibility. |
37 | 37 |
|
38 | 38 | ## Tunnel Configuration |
|
41 | 41 | - Supports any command-line tool that can be started/stopped; config uses `#[serde(default)]` on optional fields for backward compatibility. |
42 | 42 | - Default seed tunnels: `example-ssh`, `k8s-example`, and `colima`. |
43 | 43 |
|
| 44 | +## One-Time Commands |
| 45 | +- `[commands]` config section for fire-and-forget commands (no kill_command needed). |
| 46 | +- Each command defines `name`, `command`, `args`, and optional `output` mode (`"silent"` | `"notify"` | `"terminal"`). |
| 47 | +- `CommandRunner` in `core/src/command.rs` dispatches execution based on output mode using platform-specific callbacks (notify and terminal). |
| 48 | +- `scripts_dir` config option auto-discovers `*.sh` files and adds them as commands with `"notify"` output mode. |
| 49 | +- Menu order: Tunnels → Commands → Scheduled Tasks → system items. |
| 50 | + |
44 | 51 | ## Configuration Management |
45 | 52 | - If config loading fails, fall back to hardcoded defaults. |
46 | 53 | - `path` config entry controls PATH used for child processes; defaults include Homebrew locations. |
|
0 commit comments