Skip to content

refactor(cli): hoist require_api_key and reuse CI-detection check - #46

Draft
The64thRealm wants to merge 1 commit into
commands-to-delete-specific-playtest-datafrom
worktree-dedupe-require-api-key
Draft

refactor(cli): hoist require_api_key and reuse CI-detection check#46
The64thRealm wants to merge 1 commit into
commands-to-delete-specific-playtest-datafrom
worktree-dedupe-require-api-key

Conversation

@The64thRealm

Copy link
Copy Markdown
Contributor

What

Two dedup cleanups following review feedback on the clear-playtest-data command. No behavior change.

require_api_key() → shared auth::require_api_key

It turned out to be a verbatim copy in four modules (achievements, stats, init, clear_playtest_data), not two. Hoisted into auth.rs as pub(crate) fn require_api_key() so the "Not authenticated" message and the AuthSource match stay in sync in one place. All four call sites now import and use it; init.rs keeps its AuthManager/AuthSource import because its interactive handle_init flow still uses them directly.

is_non_interactive() → reuse is_browser_login_unavailable()

clear_playtest_data::is_non_interactive() reimplemented main.rs's is_browser_login_unavailable() + env_flag_enabled() (its own doc comment said "Mirrors is_browser_login_unavailable in main.rs"). Made both pub(crate) and reused is_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 removed IsTerminal/AuthSource imports)
  • doppler run -- cargo test — 3 passed

Note

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

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>
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