module-starter icon indicating copy to clipboard operation
module-starter copied to clipboard

Using force removes the entire module directory

Open ghandmann opened this issue 2 years ago • 0 comments

Hi there,

i stumbled upon your module today and tried it out (v1.77). I was surprised by the --force behavior for existing directories. Because it simply removes the given directory completely (with remove_tree from File::Path) and then recreates it. Therefore not only "overwriting" it, but effectively wiping it (and for example an existing .git/ directory as well).

My use case of first writing the source code and then scratching my head on how to create a CPAN distribution may not be the intended use case of your module.

But i was more or less expecting that it would just overwrite files already existing, instead of wiping the entire folder. (That at least also describes the usage output for --force: Delete pre-existing files if needed). In case the target directory already exists, the program advertises the --force option in order to stomp the directory. Which is in some way "descriptive" of what will happen, but not that clear in relation to the consequences. ;)

In my case nothing bad happened, everything was pushed to the remote before i started playing with your module. So i could easily recreate my project.

But i think this behavior should either be documentend/communicated way better or - what i would prefer - should be changed to just delete/overwrite the files, the module actually generates.

This way it would be easy to try out the module, check git diff to see what it was doing and maybe just roll back with git restore -- .. The current behavior makes this impossible.

By changing this, it would also be possible to create a new module from within the folder you want to start, instead from a top-level folder. (e.G.: module-starter --dir=. --module=Some::Module).

ghandmann avatar Feb 07 '22 14:02 ghandmann