Skip to content

Negative flag parsing too permissive (e.g. --no-b-alias, -no-boolean) #209

@BobbieGoede

Description

@BobbieGoede

Environment

Node 22.19 (lts)
Latest commit

Reproduction

  1. Checkout latest commit
  2. Change the static argument at playground/commands/deploy.ts:25
    static: {
      type: "boolean",
      description: "Don't include the files in the CWD as static files",
--    default: false,
++    default: true,
++    alias: 's'
    },
  1. Observe the parsed output with these invalid flags
Command static
pnpm play deploy -no-static foo false
pnpm play deploy --no-s foo false

Describe the bug

Negative flags are parsed and accept mixed short and long dash prefixes regardless of being an alias or not.

This means that a (default: true) boolean argument named foo-boolean with an alias fb would parse the following negative formats:

  • --no-foo-boolean
  • -no-foo-boolean (unexpected)
  • -no-fb (not sure)
  • --no-fb (not sure)

Additional context

Honestly, the short prefix on negative aliases look weird to me 😅

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions