Skip to content

fix: read short flags joined with equals (#118) - #120

Merged
paureis merged 5 commits into
paureis:mainfrom
Zaygalx:fix/118-short-flag-equals
Nov 5, 2026
Merged

paureis merged 5 commits into
paureis:mainfrom
Zaygalx:fix/118-short-flag-equals

Conversation

@Zaygalx

@Zaygalx Zaygalx commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

What

Fixes #118.

flagValue in src/args.ts only recognized the = form for long names, because the branch was guarded by name.startsWith("--"). A command such as wrangler deploy -e=production therefore looked like it had no --env value; cloudflare.resolve fell through to the top-level account or whoami instead of the [env.production] account.

The shared reader now accepts name=value for both short and long flag names. Names without = behave exactly as before.

Tests

  • Added test/args.test.ts: the new test failed before the change with expected undefined to be 'production' and passes after it.
  • Added a Cloudflare resolver assertion: wrangler deploy -e=production resolves the [env.production] account.
  • npm run typecheck: passed.
  • npm test: 42 files passed, 1067 passed, 7 skipped.
  • npm run build: passed.
  • git diff --check: clean.

CLI behavior

Wrangler uses yargs and accepts the short joined form (the failure described in #118). The long form is unchanged. This change only affects names already passed to flagValue; Azure, AWS, gcloud, GitHub and Supabase continue to pass long names only.

AI assistance

This change was prepared with AI coding assistance under the repository's AGENTS.md and CONTRIBUTING.md rules. I reviewed the diff and ran the checks above.

@paureis

paureis commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Thanks for this, and for the clear write-up. It's cloudpin's first outside contribution.

I checked #118's first to-do item for every CLI that passes a short name to flagValue:

  • Wrangler (yargs) accepts -e=production and -c=path, so your change is right there.
  • Vercel uses arg 5.0.0, which doesn't accept -T=acme: it splits it into -T -= -a ... and exits 1 with
    ARG_MISSING_REQUIRED_SHORTARG. Nothing runs, but Short flags joined with = (-e=production) aren't read #118 asks that cloudpin not read -x=value where the CLI doesn't.
  • kubectl and helm already read -n=web through their own parser; the others pass long names only.

Two small changes, please:

  1. Make the short = form opt-in, e.g. flagValue(args, names, { shortEquals: true }), used from cloudflare.ts and
    wrangler-dotenv.ts, with a test that flagValue(["-T=acme"], ["--team", "-T"]) stays undefined.
  2. Move the CHANGELOG line into the 1.3.0 [Unreleased] section once 1.2.0 is tagged.

On timing: #118 is in the 1.3.0 milestone, and main only takes 1.2.0 work until v1.2.0 is tagged on Thursday
2026-11-05. So this waits until then, and I'll merge it after the tag. CI will run once I've approved the workflow
for a first-time contributor.

@Zaygalx

Zaygalx commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Both changes are in, thanks for the detailed check.

  • flagValue now takes { shortEquals: true }, and only cloudflare.ts and wrangler-dotenv.ts pass it. The new test asserts flagValue(["-T=acme"], ["--team", "-T"]) stays undefined; long = values and separate short values are unchanged.
  • I merged current main, which also resolves the CHANGELOG conflict, and kept the entry under the 1.3.0 [Unreleased] section.

Local verification: npm run typecheck, npm test (1272 passed, 7 skipped) and npm run build all pass. Head is 0b3445e.

@paureis

paureis commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Thanks, both changes look right, and CI is green. I'll merge this after v1.2.0 is tagged on Thursday 2026-10-29 (the release moved up a week).

@Zaygalx

Zaygalx commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Okay, got ya. Thanks for the quick review, I'll keep an eye out after the 29th.

paureis and others added 2 commits November 4, 2026 18:26
cloudflare.ts: main's profile lookup, with shortEquals on the --env read. The
CHANGELOG line moves under [Unreleased]; ROADMAP says done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CHANGELOG keeps both sides' lines under [Unreleased].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paureis
paureis merged commit bfd44c1 into paureis:main Nov 5, 2026
4 checks passed
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.

Short flags joined with = (-e=production) aren't read

2 participants