Repository navigation
feat: add preview_command API for inspecting what would be launched - #12
Merged
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an additive
preview_command(path, app_id) -> io::Result<CommandPreview>public API that returns the program + argv thatopen()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>specta::Typebehind the existingspectafeature flag.Tests
preview_command_for_argv_app_returns_program_and_pathpreview_command_for_obsidian_returns_uri(macOS only)preview_command_for_unknown_app_id_returns_not_foundThe
Unsupportedcase 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, orFileSupport.Release
Bumped to 0.3.0. CHANGELOG updated.