refactor(cli): hoist require_api_key and reuse CI-detection check - #46
Draft
The64thRealm wants to merge 1 commit into
Draft
Conversation
require_api_key() was duplicated verbatim across four modules (achievements, stats, init, clear_playtest_data). Hoist it into auth.rs as a pub(crate) fn so the "Not authenticated" message and the AuthSource match live in one place. clear_playtest_data's is_non_interactive() reimplemented main.rs's is_browser_login_unavailable() + env_flag_enabled(). Make those pub(crate) and reuse is_browser_login_unavailable() directly so the CI-detection logic can't drift between copies. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Two dedup cleanups following review feedback on the clear-playtest-data command. No behavior change.
require_api_key()→ sharedauth::require_api_keyIt turned out to be a verbatim copy in four modules (
achievements,stats,init,clear_playtest_data), not two. Hoisted intoauth.rsaspub(crate) fn require_api_key()so the"Not authenticated"message and theAuthSourcematch stay in sync in one place. All four call sites now import and use it;init.rskeeps itsAuthManager/AuthSourceimport because its interactivehandle_initflow still uses them directly.is_non_interactive()→ reuseis_browser_login_unavailable()clear_playtest_data::is_non_interactive()reimplementedmain.rs'sis_browser_login_unavailable()+env_flag_enabled()(its own doc comment said "Mirrorsis_browser_login_unavailablein main.rs"). Made bothpub(crate)and reusedis_browser_login_unavailable()at the confirmation-guard call site so the CI-detection logic can't drift.Verification
doppler run -- cargo clippy --all-targets -- -D warnings— clean (no unused-import warnings from the removedIsTerminal/AuthSourceimports)doppler run -- cargo test— 3 passedNote
Based on
commands-to-delete-specific-playtest-data(where this code lives), so it targets that branch rather than the default branch.🤖 Generated with Claude Code