NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.04k stars 1.36k forks source link

task parameters are treated as unrecognized global parameters #5353

Closed alcuadrado closed 1 month ago

alcuadrado commented 1 month ago

Version of Hardhat

v-next

What happened?

If you try to run this in the new v-next/example-package you'll get an error

pnpm hardhat hello --greeting asd
/workspaces/hardhat/v-next/hardhat/src/internal/cli/main.ts:382
      throw new HardhatError(
            ^

HardhatError: HHE304: Invalid parameter --greeting. It is neither a valid global parameter nor associated with any task. Did you forget to add the task first, or did you misspell it?
    at parseDoubleDashArgs (/workspaces/hardhat/v-next/hardhat/src/internal/cli/main.ts:382:13)
    at parseGlobalArguments (/workspaces/hardhat/v-next/hardhat/src/internal/cli/main.ts:222:3)
    at main (/workspaces/hardhat/v-next/hardhat/src/internal/cli/main.ts:70:41) {
  [cause]: undefined
}

Node.js v22.2.0

I think this was probably introduced with the refactor to the task parsing logic.

We should add a regression test and fix it.

Minimal reproduction steps

Described above.

Search terms

No response