I've added two methods to Thor::Actions for modifying the ownership of a file or directory using FileUtils.chown_R (much like the existing chmod action).
The methods are Thor::Actions#chown for changing both user and group (or one of them if the other is passed as nil) and Thor::Actions#chgrp for only changing the group.
Add Thor::Actions#chown for changing the owner and group of a file or…
Add Thor::Actions#chgrp to change the group of a file or directory.
Thanks for your pull request. However, calling such actions are fairly easy with FileUtils, what is the benefit of moving them to Thor? They are not frequently used as well, so I don't see much benefit.
Thanks for the prompt response, José.
I found myself wanting a #chown action while developing a Thor-powered CLI that creates configuration files that need to be group-writable. Thor already provides #chmod which took care of the permissions but I also wanted to modify ownership. I thought they were suitable for inclusion within Thor::Actions as they are come under file manipulation and may be useful along with #empty_directory and #template for the creation of new files.
As for the benefit over using FileUtils directly, I saw them as being a natural partner to the existing #chmod and so would benefit from the same logging and pretend functionality given there. That said, I can understand that #chmod has a key use case for making files executable that doesn't involve file ownership.
Ok, thanks! I will leave it open for a while. Let's see if other people need them as well.
Improve status logging for Thor::Actions#chmod, #chown and #chgrp.
I'd use it as well (chown). I have a helper to achieve this.
It might be worth noting that I have made another commit to make the logging provided by #chown, #chmod and #chgrp slightly more useful: mudge@8bf9c85
I would like those actions to be included. Mostly because they trigger important changes to the system and I'd like those changes being logged. I could life with them being only available using FileUtils, too. #chmod should probably be marked as deprecated in this case, IMHO.
Good work anyway:-)
This pull request no longer merges cleanly. If you are still interested in this patch being merged into master, please rebase your branch.