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

[spiral/console] Add the ability to use enum as console option #1036

Merged
merged 3 commits into from
Dec 21, 2023

Conversation

msmakouz
Copy link
Member

Q A
Bugfix?
Breaks BC?
New feature? ✔️

The ability to use Enum as an option in a console command when configuring it with attributes has been added. For example, option Status in the example below:

use App\Domain\User\Status;
use Spiral\Console\Attribute\Argument;
use Spiral\Console\Attribute\AsCommand;
use Spiral\Console\Attribute\Option;
use Spiral\Console\Attribute\Question;
use Spiral\Console\Command;

#[AsCommand(name: 'app:create-user', description: 'Create user')]
final class CreateUser extends Command
{
    #[Argument(description: 'User email')]
    #[Question(question: 'Provide user email')]
    private string $email;

    #[Option(description: 'User status')]
    private Status $status;

    public function __invoke(): int
    {
        // ...
    }
}

@msmakouz msmakouz added this to the 3.11 milestone Dec 20, 2023
@msmakouz msmakouz self-assigned this Dec 20, 2023
Copy link

codecov bot commented Dec 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (059b9ca) 89.27% compared to head (e8a8329) 89.27%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1036   +/-   ##
=========================================
  Coverage     89.27%   89.27%           
- Complexity     6223     6228    +5     
=========================================
  Files           818      818           
  Lines         17506    17516   +10     
=========================================
+ Hits          15628    15638   +10     
  Misses         1878     1878           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@butschster butschster merged commit 93b7da8 into master Dec 21, 2023
13 of 14 checks passed
@butschster butschster deleted the feature/console-options-enum branch December 21, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants