Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow environment extension before parsing cli arguments #4950

Closed
theethernaut opened this issue Mar 1, 2024 · 0 comments
Closed

Allow environment extension before parsing cli arguments #4950

theethernaut opened this issue Mar 1, 2024 · 0 comments
Assignees
Labels
status:ready This issue is ready to be worked on type:improvement

Comments

@theethernaut
Copy link
Contributor

theethernaut commented Mar 1, 2024

I'm working in an interactivity plugin, that uses enquirer to collect arguments that were not provided when calling any task.

For example, if one were to call npx hardhat run (notice the <script> argument missing), this would produce the error:

Error HH307: Missing positional argument script

With this plugin, you would instead get:

? Enter script (A js file to be run within hardhat's environment): › ...

This is easily done by traversing all the tasks in the hre and changing isOptional to false, given that in my interactive mode, all arguments are treated equal.

However, the plugin throws when I reach this point, because environment extensions occur right after argument parsing.

I believe that giving us the option to modify task definitions before parsing occurs should be as simple as moving the line that creates the Environment object in packages/hardhat-core/src/internal/cli/cli.ts a few lines up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on type:improvement
Projects
Archived in project
Development

No branches or pull requests

3 participants