Skip to content

feat: add non-interactive session checking to modern commands#10134

Open
paulbalandan wants to merge 1 commit intocodeigniter4:4.8from
paulbalandan:non-interactive-mode
Open

feat: add non-interactive session checking to modern commands#10134
paulbalandan wants to merge 1 commit intocodeigniter4:4.8from
paulbalandan:non-interactive-mode

Conversation

@paulbalandan
Copy link
Copy Markdown
Member

@paulbalandan paulbalandan commented Apr 23, 2026

Description
Adds a non-interactive session capability to the modern AbstractCommand framework introduced in #10120. Previously interact() always fired, so modern commands could hang on CLI::prompt() when run in CI, cron, or piped contexts.

This PR adds:

  • A reserved default option on every modern command: --no-interaction / -N.
  • Public API on AbstractCommand: isInteractive(): bool and setInteractive(bool): static.
  • Precedence: explicit setter > CLI flag > STDIN TTY detection.
  • Automatic cascade of the non-interactive state to sub-commands invoked via $this->call(...); a caller-supplied flag wins over propagation.
  • A new ?bool $noInteractionOverride parameter on call(): null (default) propagates, true forces non-interactive, false strips any inherited --no-interaction so the child resolves its own state.
  • logs:clear now shows its --force hint only in non-interactive mode, resolving an existing @todo.

Note
The shortcut is -N (capital) rather than -n because several legacy migration commands: migrate, migrate:refresh, migrate:rollback already use -n as the shortcut for --namespace. Capital -N leaves that shortcut free if any of those commands are later migrated to AbstractCommand.

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

@github-actions github-actions Bot added the 4.8 PRs that target the `4.8` branch. label Apr 23, 2026
@paulbalandan paulbalandan force-pushed the non-interactive-mode branch from 23fd7fd to 409db29 Compare April 23, 2026 19:01
@paulbalandan paulbalandan force-pushed the non-interactive-mode branch from 409db29 to 6cfa8ce Compare April 23, 2026 19:25
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant