staticrypt
staticrypt copied to clipboard
Add --overwrite flag to staticrypt
Fixes #196
Add support for the --overwrite flag to overwrite files in-place.
-
cli/helpers.js
- Add
overwriteparameter togetFullOutputPathandrecursivelyApplyCallbackToHtmlFilesfunctions. - Update
parseCommandLineArgumentsto include the--overwriteoption.
- Add
-
cli/index.js
- Update
runStatiCryptfunction to handle the--overwriteflag. - Update
encodeAndGenerateFilefunction to handle the--overwriteflag.
- Update
-
README.md
- Add documentation for the
--overwriteflag in the CLI section. - Add an example of using the
--overwriteflag.
- Add documentation for the
Thank you @defineprogramming, this PR looks very clean to me!
I want to play with it a little bit, I wonder if there would be a simpler way to get this flag working by setting the output directory to the input directory and not having to change any function signature. Otherwise that looks good to me. I'll comment back once I get to explore that, hopefully soon.
Thank you for moving this forward!
(Quick update - I've been looking into this and trying things out but have been quite busy and haven't had enough time to reach more of a conclusion on that topic. I really want to refactor these index.js and helper.js which are all over the place with their functions with too many parameters, but it might make sense to do that after your PR. So just letting you know I haven't forgotten it and will get to it at some point!)
Just naively thinking about this, wouldn't it be simpler to say if -d is specified, then output to a folder and if not specified, overwrite. The -r is also kind of redundant. If the input is a file or list of files, then encrypt them. If input is a folder then, it must be recursive.