I'm using the Thor built-in action "copy_file" to copy a file from my template source, overwriting an existing file.
I always want to overwrite, and don't want to have to confirm this interactively.
The documentation doesn't suggest there is a force option in the config hash for this action, but http://textmate.rubyforge.org/thor/Thor/Actions.html does indicate that config[:behavior] can be set to force, but I can't see how to do this.
If anyone has an example of doing this that they could share, I'd be most grateful.
Thanks.
Look at the source of copy_file
action at https://github.com/erikhuda/thor/blob/master/lib/thor/actions/file_manipulation.rb it uses create_file
and passes config Hash to it. Ok, let us see specs for create_file https://github.com/erikhuda/thor/blob/master/spec/actions/create_file_spec.rb . Search the file for 'force', action can be invoked with:
create_file("doc/config.rb", :force => true)
Try that with your copy_file
action, append :force => true
at the end, it is treated as config hash, passed to create_file and it should work.