Skip to content

feat: offer to run a suggested command when the typed name is not found - #10538

Merged
paulbalandan merged 1 commit into
codeigniter4:4.8from
paulbalandan:command-suggestion-confirm
Sep 15, 2026
Merged

paulbalandan merged 1 commit into
codeigniter4:4.8from
paulbalandan:command-suggestion-confirm

Conversation

@paulbalandan

Copy link
Copy Markdown
Member

Description

When a command name is not found, spark already lists the closest matches. On an interactive run it now also offers to run one of them.

Single match:

$ php spark cache:clea

Command "cache:clea" not found.

Run "cache:clear" instead? [y, n]: y
Cache cleared using the "file" driver.

Several matches:

$ php spark clear

Command "clear" not found.

Select a command to run instead:
  [0]  cache:clear
  [1]  debugbar:clear
  [2]  logs:clear
  [3]  none of these

[0, 1, 2, 3]: 0
Cache cleared using the "file" driver.

Declining (n, or none of these) runs nothing and exits with EXIT_ERROR. The chosen command receives the original arguments and options.

Non-interactive runs (--no-interaction / -N, piped input, or a NullInputOutput sink) are unchanged:

$ php spark cache:clea -N

Command "cache:clea" not found.

Did you mean this?
    cache:clear

Note: Commands::getCommandAlternatives() is now public (recorded under Method Scope Changes).

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 Sep 9, 2026
@paulbalandan paulbalandan added the enhancement PRs that improve existing functionalities label Sep 9, 2026

@neznaika0 neznaika0 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.

Nice feature

Comment thread system/CLI/Console.php
Comment thread user_guide_src/source/changelogs/v4.8.0.rst

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

I think we should also mention the method's visibility change in the upgrade notes. Something short, like:

If you extend CodeIgniter\CLI\Commands and override getCommandAlternatives(), change the override's visibility from protected to public.

@github-actions github-actions Bot added the stale Pull requests with conflicts label Sep 12, 2026
@github-actions

This comment was marked as resolved.

@paulbalandan
paulbalandan force-pushed the command-suggestion-confirm branch from 31bdbf2 to 99cc880 Compare September 12, 2026 12:34
@paulbalandan paulbalandan removed the stale Pull requests with conflicts label Sep 12, 2026
@paulbalandan

Copy link
Copy Markdown
Member Author

Looks good!

I think we should also mention the method's visibility change in the upgrade notes. Something short, like:

If you extend CodeIgniter\CLI\Commands and override getCommandAlternatives(), change the override's visibility from protected to public.

Added

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@carson-codeigniter4 carson-codeigniter4 Bot added the stale Pull requests with conflicts label Sep 15, 2026
@carson-codeigniter4

This comment has been minimized.

@paulbalandan
paulbalandan force-pushed the command-suggestion-confirm branch from 99cc880 to 2b018fe Compare September 15, 2026 08:38
@carson-codeigniter4 carson-codeigniter4 Bot removed enhancement PRs that improve existing functionalities stale Pull requests with conflicts labels Sep 15, 2026
@paulbalandan paulbalandan added the new feature PRs for new features label Sep 15, 2026
@paulbalandan
paulbalandan merged commit 1a9ba5e into codeigniter4:4.8 Sep 15, 2026
70 of 74 checks passed
@paulbalandan
paulbalandan deleted the command-suggestion-confirm branch September 15, 2026 10:33
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. new feature PRs for new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants