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

Provide a way to parse command line options into BuildOptions #4079

Open
hagabaka opened this issue Feb 14, 2025 · 1 comment
Open

Provide a way to parse command line options into BuildOptions #4079

hagabaka opened this issue Feb 14, 2025 · 1 comment

Comments

@hagabaka
Copy link

It seems that if you use a build script and want it to also handle command line options, you have to write code to handle them yourself (#3383). It would be nice if there is an API to parse BuildOptions from process.argv, so that a build script can just use that and merge them into options parsed to build.

My use case is that I want to have a "build" script in package.json, and want to sometimes invoke it with the --watch option to use the watch mode.

@hyrious
Copy link

hyrious commented Feb 14, 2025

esbuild's command args style are quite simple (it doesn't parse spaced arguments like --key value). You can implement a parser which behave exactly the same as esbuild easily: https://github.com/hyrious/esbuild-dev/blob/main/src/args.ts

Here's another implementation used in esbuild.try: https://github.com/esbuild/esbuild.github.io/blob/main/src/try/options.ts#L51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants