Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Add --name option to schedule:test command #41439

Merged
merged 2 commits into from Mar 11, 2022
Merged

[9.x] Add --name option to schedule:test command #41439

merged 2 commits into from Mar 11, 2022

Conversation

ziadoz
Copy link
Contributor

@ziadoz ziadoz commented Mar 11, 2022

It would be handy to be able to schedule commands for testing using their name, rather than having to choose from a list, as often I'm looking to run a specific command, and the list numbers change as new commands are added to the schedule. This PR adds an optional --name option to schedule:test to make that possible.

It works by matching the end of the strings contained in $commandNames, which looks like this:

  0 => "'/usr/local/bin/php' 'artisan' my:cmd-1"
  1 => "'/usr/local/bin/php' 'artisan' my:cmd-2"
  2 => "named-cmd-1"
  3 => "named-cmd-2"
  4 => "App\Commands\ClassCmd"

So --name=my:cmd-1 would match 0, --name=named-cmd-2 would match 3, and --name=ClassCmd would match 4. If there isn't an exact match then an error is returned.

I couldn't see a test class for this command, so I haven't added any additional test cases, but if someone points me in the right direction I'll happily add them. Thanks.

@taylorotwell taylorotwell merged commit 8b0af92 into laravel:9.x Mar 11, 2022
@ziadoz ziadoz deleted the schedule-test-command-name-option branch March 11, 2022 14:29
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.

None yet

2 participants