Skip to content

feat: allow modern commands to opt out of the spark header - #10597

Merged
paulbalandan merged 1 commit into
codeigniter4:4.8from
paulbalandan:command-no-header
Oct 9, 2026
Merged

paulbalandan merged 1 commit into
codeigniter4:4.8from
paulbalandan:command-no-header

Conversation

@paulbalandan

Copy link
Copy Markdown
Member

Description
Adds #[Command(headerless: true)], which suppresses the spark header for that command, with the same effect as always passing --no-header. A command whose output is read by another program, such as JSON piped to jq or CSV redirected to a file, otherwise relies on every caller passing the flag, and one caller without it breaks the output from the first line. help <command> and <command> --help still print the header.

Deciding this requires the command registry before the header is printed, and building the registry runs discovery. The duplicate legacy/modern name warning printed during discovery now goes to STDERR, so it neither precedes the header on STDOUT nor ends up in a headerless command's output.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@carson-codeigniter4 carson-codeigniter4 Bot added the 4.8 PRs that target the `4.8` branch. label Oct 5, 2026
@paulbalandan paulbalandan added the enhancement PRs that improve existing functionalities label Oct 5, 2026
@paulbalandan
paulbalandan requested a balanced review from Copilot October 5, 2026 14:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The compatibility-sensitive STDERR migration lacks the required 4.8 upgrading-guide entry.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Adds an opt-in headerless flag for modern Spark commands targeting CodeIgniter 4.8.

Changes:

  • Adds headerless command metadata and lookup APIs.
  • Suppresses headers for marked commands and aliases while preserving help headers.
  • Routes duplicate-command warnings to STDERR and adds tests/documentation.

The STDERR behavior change still needs migration guidance in upgrade_480.rst.

File Description
system/​CLI/​Console.php Applies command-level header suppression.
system/​CLI/​Commands.php Registers/query headerless metadata; moves warnings to STDERR.
system/​CLI/​AbstractCommand.php Exposes isHeaderless().
system/​CLI/​Attributes/​Command.php Adds the headerless attribute argument.
tests/​system/​CLI/​ConsoleTest.php Tests suppression and help behavior.
tests/​system/​CLI/​CommandsTest.php Tests registry metadata and shadowing.
tests/​system/​CLI/​AbstractCommandTest.php Tests command-level accessor.
tests/​system/​CLI/​Attributes/​CommandTest.php Tests attribute defaults and values.
tests/​_support/​Commands/​Modern/​HeaderlessCommand.php Adds a headerless fixture.
tests/​_support/​Duplicates/​HeaderlessDuplicateModern.php Adds a shadowing fixture.
user_guide_src/​source/​cli/​spark_commands.rst Links headerless-command guidance.
user_guide_src/​source/​cli/​cli_modern_commands.rst Documents the feature and API.
user_guide_src/​source/​cli/​cli_modern_commands/​017.php Adds a JSON-output example.
user_guide_src/​source/​changelogs/​v4.8.0.rst Records the enhancement.

Validation: no local tests were run; CI remains authoritative.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread system/CLI/Commands.php
@paulbalandan
paulbalandan merged commit d219b08 into codeigniter4:4.8 Oct 9, 2026
59 checks passed
@paulbalandan
paulbalandan deleted the command-no-header branch October 9, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch. enhancement PRs that improve existing functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants