Skip to content

refactor(cli): extract parseFlags helper from 302-line main()#3355

Open
la14-1 wants to merge 1 commit intomainfrom
refactor/extract-parse-flags-helper
Open

refactor(cli): extract parseFlags helper from 302-line main()#3355
la14-1 wants to merge 1 commit intomainfrom
refactor/extract-parse-flags-helper

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented Apr 24, 2026

Why: main() at 302 lines is the largest uncovered function; flag-parsing extraction reduces it by ~220 lines and isolates all argument handling.

Summary

  • Extract parseFlags() async function that handles all global flag parsing and returns a typed ParsedFlags object
  • Extract reusable helpers: extractBooleanFlag, extractEnvFlag, extractValueToEnv, extractValue, validateBetaFeatures
  • main() reduced from 302 lines to 84 lines (72% reduction)
  • Zero behavioral changes — all flag parsing, env var setting, config loading, and validation preserved exactly

Test plan

  • bunx @biomejs/biome check src/ passes with zero errors
  • bun test passes (2106/2108, 2 pre-existing flaky failures in digitalocean-token.test.ts unrelated to this change)
  • Verified main() line count: 302 → 84

-- spawn-refactor/complexity-hunter

@la14-1 la14-1 marked this pull request as ready for review April 24, 2026 16:27
@la14-1 la14-1 force-pushed the refactor/extract-parse-flags-helper branch from ddecedf to 9e17053 Compare April 25, 2026 08:21
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 25, 2026

Rebased onto main to resolve merge conflicts. Added --repo flag extraction (from #3360) to the parseFlags helper to keep it in sync with main.

-- refactor/pr-maintainer

@la14-1 la14-1 force-pushed the refactor/extract-parse-flags-helper branch from 9e17053 to 68da205 Compare April 28, 2026 03:05
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 28, 2026

Rebased onto main to resolve merge conflicts. Integrated the initFeatureFlags() call and fast_provision experiment code (from #3366) into the parseFlags helper. Lint and tests pass (2 pre-existing failures, same as main).

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 28, 2026

This PR has been open for 4+ days with all CI checks passing (ShellCheck, Biome Lint, Unit Tests, Mock Tests, macOS Compatibility — all SUCCESS). It is mergeable with no conflicts.

Requesting human review when convenient.

-- spawn-refactor/pr-maintainer

@la14-1 la14-1 force-pushed the refactor/extract-parse-flags-helper branch from 68da205 to 91edd1f Compare April 29, 2026 20:29
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented Apr 29, 2026

Rebased onto main to resolve merge conflict from #3371 (narrowed fast_provision experiment to images-only). Updated the parseFlags helper to match: betaFeatures.push("images") instead of "tarball", "images". Lint passes, tests pass (2 pre-existing flaky failures, same as main).

-- refactor/pr-maintainer

@la14-1 la14-1 force-pushed the refactor/extract-parse-flags-helper branch from 91edd1f to a52f800 Compare April 30, 2026 05:08
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 3, 2026

This PR is ready for review. All CI checks pass and there are no merge conflicts.

-- refactor/pr-maintainer

Extract flag-parsing logic into a dedicated parseFlags() function,
reducing main() from 302 lines to 84 lines. Also extracts reusable
helpers: extractBooleanFlag, extractEnvFlag, extractValueToEnv,
extractValue, and validateBetaFeatures.

Agent: complexity-hunter
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@la14-1 la14-1 force-pushed the refactor/extract-parse-flags-helper branch from a52f800 to 6076157 Compare May 3, 2026 14:19
@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 3, 2026

Rebased onto main (was 4 commits behind). Clean rebase, no conflicts.

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 4, 2026

Verified in worktree: tests pass (2236/2238, same 2 pre-existing failures as main), lint clean (biome 0 errors). PR is mergeable and ready for review.

-- refactor/pr-maintainer

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.

2 participants