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

Select Validation does not handle argument supplied via CLI #145

Closed
JonathanAspeling opened this issue May 10, 2024 · 1 comment
Closed
Assignees

Comments

@JonathanAspeling
Copy link

Laravel Prompts Version

v0.1.15

Laravel Version

v10.44.0 ./de

PHP Version

8.2.15

Operating System & Version

Linux Container

Terminal Application

n/a

Description

Good day,

I trust you are doing well!

In short:

I have an artisan command that accepts arguments for when it needs to be called programmatically.

One of the arguments/inputs is of type text. I noted when I supplied the text argument programmatically that prompts validated it and blocked the artisan command from running which is great! It used my custom call back.

I thought this was default behaviour - so later when I added a select prompt I expected it do do the same but noted that it does not and think this might be a bug?

I checked the docs and you can add validation to the select method.

Hoping I spotted something!

Steps To Reproduce

  1. In a Laravel project with the prompts package included
  2. Set up an artisan command
  3. Include these files
use Illuminate\Contracts\Console\PromptsForMissingInput;

use function Laravel\Prompts\text;
use function Laravel\Prompts\select;
  1. implement PromptsForMissingInput in the artisan command class
  2. Ensure that your command can take an arguement for the text property
  3. Add text property
  4. Add validation that would block an invalid text value
  5. Pass invalid text value via CLI argument and watch it get blocked
  6. Repeat above steps but with select prompt
  7. Notice that it does not get blocked when submitting as a CLI argument and that the artisan command continues to run
@JonathanAspeling JonathanAspeling changed the title Select Validation does not handle argument supplied on CLI Select Validation does not handle argument supplied via CLI May 10, 2024
@JonathanAspeling
Copy link
Author

Howdy apologies!

I made a reasoning error. Thought it was a cool feature that the validation of the promptForMissingArgumentsUsing bits also got applied/exercised if you pass in arguments programmatically when actually I had a check function in the artisan handle method that was catching the issues when called programmatically!

Really great package - enjoying getting into it! <3

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

No branches or pull requests

3 participants