-
Notifications
You must be signed in to change notification settings - Fork 132
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
Spark cli user command #579
Conversation
@robertogerola Thanks, can you write the php unit test for this PR? see : Also add descriptions to documents. |
@codeigniter4/core-team |
Personally, i would choose short options with single letters and |
Hello, just made the changes : -n for new username and -m for new email. |
Is there any command that does not need user input? |
Thanks for the command argument change, I think that is the correct way to handle it. |
I remember someone raised this issue, but I couldn't find PR/IS CI4 threads on GitHub. |
CI 4.3 provide a way to write tests for methods that require user input.
It is not good to have no test at all, so if there are commands without user input, We use mocking the test target because there is no other way. shield/tests/Commands/SetupTest.php Lines 44 to 50 in 44bbf2c
But I don't think it is good practice. Because mock is not a true product code. |
CI 4.3 was released, so you can write tests for CLI input. I think we can skip the tests for CI 4.2. |
It was wrong. 4.3 is not enough to write tests for this command. |
Closed by #833 |
Supersedes #567,#568
With the User command is possible by cli to run these actions on users :
'create', 'activate', 'deactivate', 'changename', 'changeemail', 'delete', 'password', 'list', 'addgroup', 'removegroup'
Available options :
'-i' => 'User id'
'-u' => 'User name'
'-e' => 'User email'
'-n' => 'New username'
'-m' => 'New email'
'-g' => 'Group name'
1. create a new user
./spark shield:user create -u newuser -e [email protected]
2. activate a user
by username :
./spark shield:user activate -u username
or
by email :
./spark shield:user activate -e [email protected]
3. deactivate a user
by username :
./spark shield:user deactivate -u username
or
by email :
./spark shield:user deactivate -e [email protected]
4. change user name
by username :
./spark shield:user changename -u username -n newusername
or
by email :
./spark shield:user changename -e [email protected] -n newusername
5. change user email
by username :
./spark shield:user changeemail -u username -m [email protected]
or
by email :
./spark shield:user changeemail -e [email protected] -m [email protected]
6. delete a user
by user id :
./spark shield:user delete -i 123
or
by username :
./spark shield:user delete -u user
or
by email :
./spark shield:user delete -e [email protected]
7. change a user password
by username :
./spark shield:user password -u username
or
by email :
./spark shield:user password -e [email protected]
8. list users
List all users :
./spark shield:user list
or filter by username and/or email
./spark shield:user list -u user -e [email protected]
9. add a user to a group
by username :
./spark shield:user addgroup -u username -g mygroup
or
by email :
./spark shield:user addgroup -e [email protected] -g mygroup
10. remove a user from a group
by username :
./spark shield:user removegroup -u username -g mygroup
or
by email :
./spark shield:user removegroup -e [email protected] -g mygroup
All the options are optional and if the username or email are not passed on command line, a prompt will ask the user for the necessary information to complete the required task. The data inserted are validated and every operation asks for a confirmation too proceed.