Skip to content

[CLI-util] Replace Xdebug console logs with CLI output#3460

Open
mho22 wants to merge 1 commit intotrunkfrom
replace-xdebug-console-logs-with-cli-output
Open

[CLI-util] Replace Xdebug console logs with CLI output#3460
mho22 wants to merge 1 commit intotrunkfrom
replace-xdebug-console-logs-with-cli-output

Conversation

@mho22
Copy link
Copy Markdown
Collaborator

@mho22 mho22 commented Apr 2, 2026

Motivation for the change, related issues

Both @php-wasm/cli and @wp-playground/cli duplicate the same inline ANSI formatting helpers and use raw console.log calls for Xdebug output. This makes the output inconsistent across CLIs and harder to maintain.

This pull request extracts a shared CLIOutput base class into @php-wasm/cli-util and replaces all Xdebug-related console.log calls with it in both CLIs.

Implementation details

  • New CLIOutput class in @php-wasm/cli-util : provides TTY-aware ANSI formatting and generic output methods. Uses a configurable writeStream and respects a verbosity setting.
  • @php-wasm/cli: removed standalone formatting functions and /* eslint-disable no-console */. Imports CLIOutput from @php-wasm/cli-util directly. All Xdebug console.log calls replaced with cliOutput.print().
  • @wp-playground/cli : the existing CLIOutput class now extends the base from @php-wasm/cli-util, removing its duplicated private formatting methods. Playground-specific methods remain. Standalone formatting functions in run-cli.ts removed. All Xdebug console.log calls replaced with cliOutput method calls.
  • Tests added for the base CLIOutput class covering formatting, output methods, quiet mode suppression, and getter behavior.

Testing Instructions (or ideally a Blueprint)

CLI

🧪 packages/php-wasm/cli-util/src/test/cli-output.spec.ts

@mho22 mho22 requested a review from a team April 2, 2026 23:23
Copilot AI review requested due to automatic review settings April 2, 2026 23:23
@mho22 mho22 requested review from bgrgicak and removed request for Copilot April 2, 2026 23:23
@mho22
Copy link
Copy Markdown
Collaborator Author

mho22 commented Apr 2, 2026

8 console.log remain in the packages/playground/cli/src/run-cli.ts. I am not sure I should replace them with cliOutput here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant