Skip to content

fix(cli): prevent --log-level=value from swallowing next argument#6144

Open
LikiosSedo wants to merge 2 commits intoEffect-TS:mainfrom
LikiosSedo:fix/cli-log-level-equals-syntax
Open

fix(cli): prevent --log-level=value from swallowing next argument#6144
LikiosSedo wants to merge 2 commits intoEffect-TS:mainfrom
LikiosSedo:fix/cli-log-level-equals-syntax

Conversation

@LikiosSedo
Copy link
Contributor

Summary

When using --log-level=debug (equals syntax), the SetLogLevel handler incorrectly strips the next argument too.

Root Cause

The argument filter loop checks isLogLevelArg(args[i - 1]), which matches the combined form --log-level=debug. This causes the argument at i (the one after the log-level flag) to be skipped.

args: ["--log-level=debug", "--name=hello"]

i=0: "--log-level=debug" → isLogLevelArg matches → skip (correct)
i=1: "--name=hello" → isLogLevelArg(args[0]) matches "--log-level=debug" → skip (BUG)

Fix

Change the look-back check from isLogLevelArg(args[i - 1]) to args[i - 1] === "--log-level". This ensures only the space-separated value (e.g. debug after --log-level debug) is skipped, not the argument following a combined --log-level=value form.

Reproduction

// --log-level=debug --name=hello → name = None (bug)
// --log-level debug --name=hello → name = Some("hello") (works)

Fixes #6103

When using equals syntax (--log-level=debug), the argument filter
incorrectly skips the next argument because isLogLevelArg() matches
the combined form. Only skip the next arg when the previous arg is
exactly "--log-level" (space-separated syntax).

Fixes Effect-TS#6103
@LikiosSedo LikiosSedo requested a review from IMax153 as a code owner March 25, 2026 04:48
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Mar 25, 2026
@changeset-bot
Copy link

changeset-bot bot commented Mar 25, 2026

🦋 Changeset detected

Latest commit: e8d3e86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

From Discord: Bug in Effect CLI: --log-level=debug Argument Parsing Swallows Next Argument

1 participant