staticrypt icon indicating copy to clipboard operation
staticrypt copied to clipboard

Add --overwrite flag to staticrypt

Open vuyp opened this issue 1 year ago • 3 comments

Fixes #196

Add support for the --overwrite flag to overwrite files in-place.

  • cli/helpers.js

    • Add overwrite parameter to getFullOutputPath and recursivelyApplyCallbackToHtmlFiles functions.
    • Update parseCommandLineArguments to include the --overwrite option.
  • cli/index.js

    • Update runStatiCrypt function to handle the --overwrite flag.
    • Update encodeAndGenerateFile function to handle the --overwrite flag.
  • README.md

    • Add documentation for the --overwrite flag in the CLI section.
    • Add an example of using the --overwrite flag.

vuyp avatar Sep 03 '24 09:09 vuyp

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!

robinmoisson avatar Sep 05 '24 13:09 robinmoisson

(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!)

robinmoisson avatar Oct 03 '24 14:10 robinmoisson

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.

royfrancis avatar Feb 07 '25 08:02 royfrancis