[CLI] Allow API consumers to rely upon option validation and default values - #2883
Conversation
This change allows API consumers like WordPress Studio to start Playground CLI with its built-in command line parsing. That way, consumers can use Playground CLI defaults for options like `--experimental-multi-worker` or `--experimental-unsafe-ide-integration` rather than having to provide their own defaults.
|
There is a failing test for Playground CLI: The notable bit is:
Playground CLI is downloading the WP 6.9 release candidate. This makes sense because we query https://api.wordpress.org/core/version-check/1.7/?channel=beta for the latest release. The beta channel includes the RC. If we remove the beta channel query arg, we get the latest release. It looks like we started using that URL as part of this PR: @adamziel is it intended that Playground CLI uses the beta/RC by default if one exists? |
|
Note: If I change the WP latest version query URL to https://api.wordpress.org/core/version-check/1.7/, the tests pass locally. |
|
As a user, I would expect getting the latest stable, and not beta, when I use the "latest" option. |
About to be fixed on #2889 |
|
This is also simple and low-risk. The tests pass. Let's merge. |

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)