Skip to content

fix(cli): allow vip wp --help without requiring separator#2832

Merged
sjinks merged 2 commits into
trunkfrom
fix-cli
May 18, 2026
Merged

fix(cli): allow vip wp --help without requiring separator#2832
sjinks merged 2 commits into
trunkfrom
fix-cli

Conversation

@sjinks
Copy link
Copy Markdown
Member

@sjinks sjinks commented May 11, 2026

Adjust wp separator validation so it only applies when wp command payload arguments are present, not for option-only invocations like --help.

Add regression coverage in command parser tests to ensure vip wp --help dispatches to the wp subcommand correctly.

@sjinks sjinks self-assigned this May 11, 2026
Copilot AI review requested due to automatic review settings May 11, 2026 02:58
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Adjust wp separator validation so it only applies when wp command payload
arguments are present, not for option-only invocations like --help.

Add regression coverage in command parser tests to ensure `vip wp --help`
dispatches to the wp subcommand correctly.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR relaxes the vip wp separator (--) validation so that vip wp --help (and other option-only wp invocations) can dispatch to the vip-wp subcommand without forcing a separator, and adds a regression test to ensure the behavior stays correct.

Changes:

  • Update wp subcommand validation to only require -- when “wp command payload” arguments are detected.
  • Add a command parser test covering vip wp --help dispatching to vip-wp.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/lib/cli/command.js Adjusts wp separator enforcement by introducing hasWpCommandPayload logic.
__tests__/lib/cli/command.js Adds regression coverage ensuring vip wp --help spawns the vip-wp script without requiring --.

Comment thread src/lib/cli/command.js
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

tests/lib/cli/command.js:82

  • The new regression tests cover vip wp --help and a value-taking option (--path /tmp/wp), but they don’t cover the case where a boolean WP-CLI flag precedes a command payload (e.g. vip wp --quiet plugin list). With the current hasWpCommandPayload() heuristic, those invocations can be misdetected as “option-only” and bypass the -- separator requirement; adding an explicit test for this would prevent regressions.
		it( 'allows wp option-only invocations without separator', async () => {
			const parentScript = path.join( process.cwd(), 'src/bin/vip.js' );
			const childScript = path.join( process.cwd(), 'src/bin/vip-wp.js' );

			const cmd = command( { requiredArgs: 0 } ).command( 'wp', 'Run WP-CLI commands.' );

			await cmd.argv( [ process.execPath, parentScript, 'wp', '--help' ] );

			expect( spawnSync ).toHaveBeenCalledWith( process.execPath, [ childScript, '--help' ], {
				stdio: 'inherit',
				env: process.env,
			} );
			expect( process.exit ).toHaveBeenCalledWith( 0 );
		} );

		it( 'allows wp option-only invocations with option values without separator', async () => {
			const parentScript = path.join( process.cwd(), 'src/bin/vip.js' );
			const childScript = path.join( process.cwd(), 'src/bin/vip-wp.js' );

			const cmd = command( { requiredArgs: 0 } ).command( 'wp', 'Run WP-CLI commands.' );

			await cmd.argv( [ process.execPath, parentScript, 'wp', '--path', '/tmp/wp' ] );

			expect( spawnSync ).toHaveBeenCalledWith(
				process.execPath,
				[ childScript, '--path', '/tmp/wp' ],
				{
					stdio: 'inherit',
					env: process.env,
				}
			);
			expect( process.exit ).toHaveBeenCalledWith( 0 );
		} );

		it( 'dispatches when child options appear before -- and subcommand follows separator', async () => {
			const parentScript = path.join( process.cwd(), 'src/bin/vip.js' );
			const childScript = path.join( process.cwd(), 'src/bin/vip-wp.js' );

			const cmd = command( { requiredArgs: 0 } ).command( 'wp', 'Run WP-CLI commands.' );

Comment thread src/lib/cli/command.js
Comment thread src/lib/cli/command.js
@sjinks sjinks merged commit ae45f57 into trunk May 18, 2026
19 of 20 checks passed
@sjinks sjinks deleted the fix-cli branch May 18, 2026 04:20
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

Successfully merging this pull request may close these issues.

3 participants