-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[12.x] Add option to get typed command input #58021
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
[12.x] Add option to get typed command input #58021
Conversation
and input validation like, for example, with `\Illuminate\Support\Facades\Config`
| */ | ||
| public function string(string $key, ?string $default = null): string | ||
| { | ||
| $value = match (true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is called multiple times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is called multiple times, and your code duplicates the logic for getting the value (checking argument, checking option, etc.) in several different parts of the codebase.
$value = match (true) {
$this->hasArgument($key) => $this->getArgument($key),
$this->hasOption($key) => $this->getOption($key),
default => $default ?? throw new InvalidArgumentException(sprintf('"%s" is neither an option nor an argument of this command', $key)),
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you mean, I could move that to its own method? Sure, I could, but I intend to first see if Taylor has an appetite for that
as this already exists on `Illuminate\Foundation\Console\ResourceMakeCommand` for another purpose and would cause a breaking change
Follow-up to 2067b7f
|
StyleCI can be fixed automatically upon merge as I understand it |
|
Thanks for your pull request to Laravel! Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include. If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions! |
and input validation
like, for example, with
\Illuminate\Support\Facades\Config(#50140) and\Illuminate\Support\Arr(#55567)Enhancements
Example