[CLI] Allow API consumers to rely upon option validation and default values #2883
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Motivation for the change, related issues
Today, API consumers like WordPress Studio use Playground CLI's
runCLI()method directly which skips argument validation and default values.Example here:
Automattic/studio#2058
This PR adjusts the API so consumers can rely upon CLI argument validation and default values.
Implementation details
This PR adjusts the signature of
parseOptionsAndRunCLI()to accept a string array of command line arguments so Studio can rely upon Playground CLI defaults for options like--experimental-multi-workeror--experimental-unsafe-ide-integrationrather than having to provide their own defaults.Pros
experimentalMultiWorker: -1torunCLI()is allowed by TypeScript because the value is a number, but it is an invalid number that would be caught by command line argument validation.Cons
cc @griffbrad @wojtekn
Testing Instructions (or ideally a Blueprint)