Repository navigation
fix(cli): print --version and --help instead of booting the app - #384
Merged
Merged
Conversation
The binary only looked for a project path on argv, so `--version` (a flag, therefore no project) fell through to a normal launch and opened a window. On Linux the system package's binary is what `atlas` runs, since the shell helper is not installed there, so the flag never worked. Answer --version/-v/-V and --help/-h first thing in run(), before Tauri, logging or the single-instance forward, with the same `atlas <version>` line the shell helper prints. Fixes pacifio#371
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
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.
What?
atlas --version(and--help) now print and exit when they reach the app binary, instead of opening a window.Why?
The binary only checks argv for a project path.
parse_project_pathreturnsNonefor anything starting with-, so--versionfalls through to a normal launch: the window opens and no version is ever printed (#371, seen with/usr/bin/tryatlas --versionon Arch).The
~/.local/bin/atlasshell helper already handles both flags, but it is not always in front of the binary. On Linux,cli_install_helperskips the helper when a system binary exists, soatlasis the binary there. A terminal pointed at the bundle hits the binary directly too. As the issue explains, a version check that boots a GUI instance can also take later launches as second-instance forwards.No new dependencies. I didn't add
clapfor two flags, same as the existing comment onparse_initial_projectsays.How?
commands/cli.rs:parse_info_flag(&[String]) -> Option<InfoFlag>recognises--version/-v/-Vand--help/-has the first argument (the helper accepts the same flags, plus-V).info_flag_textbuilds the output, andhandle_info_flagprints it. The version line isatlas <CARGO_PKG_VERSION>, the same line the helper prints.lib.rs:run()callshandle_info_flag()first and returns early. That happens before the profile init, logging,.envloading andtauri::Builder, so in a release build the single-instance plugin never sees the call either.cli.rs: every flag spelling is recognised. Paths, unrelated flags, and a flag that isn't the first argument are left to the normal launch. The version line is checked against theecho "atlas {{VERSION}}"line inbin/atlas-cli.sh, so the two entry points can't drift apart.Target is
0.4.1, the current version branch.Fixes #371
Checklist
I couldn't build the whole Tauri app on my Linux machine, so I haven't run the change in a window. I tested the new functions on their own: I compiled them unchanged with
rustc --test(3/3 pass) and ran them as a tiny binary (--version→atlas 0.4.1,-h→ usage,./--verbose→ normal launch path). Clippy with the workspace's deny list andrustfmt --checkare clean on both changed files. CI'scargo test --liband clippy forsrc-tauriwill run the real build.