feat: add CLI command to manage users#833
Conversation
0d08c19 to
8ead772
Compare
6bb4aba to
da466af
Compare
| $action = $params[0] ?? null; | ||
|
|
||
| if ($action === null || ! in_array($action, $this->validActions, true)) { | ||
| $this->write( |
There was a problem hiding this comment.
If not valid, display a form to select valid items.
There was a problem hiding this comment.
This PR is too big. If you want to add more features, you should send another PR.
I am more concerned about the current features working properly than usability.
There was a problem hiding this comment.
I am more concerned about the current features working properly than usability.
Ok I get it, I haven't exactly checked out this PR yet. I will try to continue with this in mind.
src/Commands/User.php
Outdated
| $this->removegroup($group, $username, $email); | ||
| break; | ||
| } | ||
| } catch (RuntimeException $e) { |
There was a problem hiding this comment.
Throw exception! If not valid, display a form to select valid items.
|
|
||
| class User extends BaseCommand | ||
| { | ||
| private static ?InputOutput $io = null; |
There was a problem hiding this comment.
$io I think it is short, and it is not understandable.
https://phpmd.org/rules/naming.html#shortvariable
src/Commands/User.php
Outdated
| if ($password !== $passwordConfirm) { | ||
| $this->write("The passwords don't match", 'red'); | ||
|
|
||
| throw new RuntimeException("The passwords don't match"); |
There was a problem hiding this comment.
Not good. Do not remove the user from the process. Display new form to re-enter data.
src/Commands/User.php
Outdated
| if ($user === null) { | ||
| $this->write("User doesn't exist", 'red'); | ||
|
|
||
| throw new RuntimeException("User doesn't exist"); |
There was a problem hiding this comment.
In all cases, I disagree with throw.
There was a problem hiding this comment.
The exception will be caught in run() method.
It is the replacement of exit().
|
@robertogerola @cijagani Try this, if you can. |
CLI::getOption() cannot use in testing now.
Co-authored-by: Pooya Parsa <pooya_parsa_dadashi@yahoo.com>
The validation rules may be an array or string.
RuntimeException is too wide.
8eef957 to
fade2c1
Compare
There was a problem hiding this comment.
I haven't had a chance to review, and I probably won't be able to for a few days.
It seems that people are waiting for this PR. You can merge.
|
Okay. The test code has been improved, so there should be no major bugs. |
Description
Supersedes #579
Closes #566
Add command
shield:userto manage users:TODO
exit()Checklist: