Repository navigation
fix(cli): handle --version/--help in the raw binary before Tauri boots - #403
Open
zichen0116 wants to merge 1 commit into
Open
zichen0116 wants to merge 1 commit into
zichen0116 wants to merge 1 commit into
Conversation
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.
Problem
tryatlas --versionopens the full application window instead of printing a version and exiting (issue #371). The shell helper (~/.local/bin/atlas) intercepts--version|-v/--help|-hitself, but invoking the raw binary directly has no such interception:run()callsparse_initial_project(), which returnsNonefor flag-like args, and Tauri boots the GUI.Fix
Intercept the first argv flag in
run()before Tauri starts:src-tauri/src/commands/cli.rs: newEarlyCliFlagenum + pureearly_cli_flag()matcher (first argv slot only,--version|-v/--help|-h, mirroring the shell helper's spellings),CLI_HELPusage text mirroring the helper, andhandle_early_cli_flags()which printsatlas <CARGO_PKG_VERSION>(0.4.0, the same source the helper bakes into its--versionbranch) or the usage text and exits 0.src-tauri/src/lib.rs: callhandle_early_cli_flags()immediately beforeparse_initial_project()inrun().Only the first argument is inspected, consistent with the shell helper checking
$1;atlas <path> --versionstill goes through the existing positional-path handling.Verification
#[cfg(test)]unit tests forearly_cli_flagcovering all four flags, empty args, non-flag args, flag-in-second-position, unknown flags, and--version=x.cargo testtarget needs the Tauri GUI dependency graph, which isn't buildable in this environment).rustfmt --checkclean;git diff --checkclean.Closes #371
Summary by CodeRabbit
--version/-vand--help/-hoptions, displayed before the app starts.