Skip to content

feat: add preview_command API for inspecting what would be launched - #12

Merged
sksizer merged 2 commits into
mainfrom
feat/preview-command-api
May 19, 2026
Merged

sksizer merged 2 commits into
mainfrom
feat/preview-command-api

Conversation

@sksizer

@sksizer sksizer commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an additive preview_command(path, app_id) -> io::Result<CommandPreview> public API that returns the program + argv that open() would spawn, without actually spawning. Use case: surfacing the effective command in a UI before launch.

What's new

  • pub struct CommandPreview { program: String, args: Vec<String> }
  • pub fn preview_command(path: &Path, app_id: &str) -> io::Result<CommandPreview>
  • Both derive specta::Type behind the existing specta feature flag.

Tests

  • preview_command_for_argv_app_returns_program_and_path
  • preview_command_for_obsidian_returns_uri (macOS only)
  • preview_command_for_unknown_app_id_returns_not_found

The Unsupported case is harder to exercise cleanly cross-platform without picking a built-in that has no entry for the current OS; skipped per the spec.

Compatibility

Additive only. No behavior changes to open(), detect_installed_apps(), PathOpener, or FileSupport.

Release

Bumped to 0.3.0. CHANGELOG updated.

sksizer added 2 commits May 19, 2026 16:16
Adds a new public function `preview_command(path, app_id) -> io::Result<CommandPreview>`
that returns the program + argv that `open()` would spawn, without actually
spawning. Use case: surfacing the effective command in a UI before launch,
or logging it for audit.

The new `CommandPreview { program, args }` struct derives `specta::Type`
behind the existing `specta` feature flag, mirroring `FileSupport` and
`PathOpener` so polish can consume it identically.

Tests cover the argv path (vscode), the Obsidian URI path (macOS), and the
NotFound error path.
Minor bump (additive public API).
@sksizer
sksizer merged commit 6129d4f into main May 19, 2026
1 check passed
@sksizer
sksizer deleted the feat/preview-command-api branch May 19, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant