Skip to content

A boolean flag before a positional swallows it #50

Description

@altaywtf

vref screenshot remove --keep-asset home fails with VREF_INVALID_BOOLEAN instead of removing home: parseArgs binds the next non-flag token as the flag's value regardless of whether the flag takes one.

It fails safe — nothing is deleted — but the message is misleading, and it hits the safety flag specifically, which is the one people reach for when they are being careful. --force and --dry-run before a positional have the same problem.

The reason it was not fixed in #48: --keep-asset home and --dry-run yes are syntactically identical. Making boolean flags stop consuming the next token turns yes into a stray positional that is then silently ignored, and test/vref.test.ts ("rejects invalid boolean safety flag values before mutating files") requires that input to be refused.

Doing this properly means per-command positional arity: boolean flags stop consuming, and any positional beyond what the command expects is refused. That changes which error code several existing inputs produce, so it wants its own change rather than riding along with a feature.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions