Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utility to write files with protection to avoid file override #14

Open
chshersh opened this issue May 19, 2022 · 1 comment
Open

Utility to write files with protection to avoid file override #14

chshersh opened this issue May 19, 2022 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@chshersh
Copy link
Owner

chshersh commented May 19, 2022

When using the writeFile function, the program silently overrides the file content. In this case, you may lose your previous content if you're careful enough.

I propose to create a new module Iris.IO and add a protected writeFile function that:

  1. Takes an argument of type: data ActionFlag = Ask | Force
  2. When Ask is given, it checks for file existence and asks a question, whether user wants to override file content.
@chshersh chshersh added the enhancement New feature or request label May 19, 2022
@chshersh chshersh moved this to Todo in Iris Project Jun 25, 2022
@chshersh chshersh added the good first issue Good for newcomers label Aug 8, 2022
@chshersh chshersh added the hacktoberfest https://hacktoberfest.com/ label Sep 27, 2022
initial-mockingbird added a commit to initial-mockingbird/iris that referenced this issue Oct 2, 2022
    * Added Yes/No functions and multiple choice functions (Issue chshersh#9).
    * Added a protected writefile function (Issue chshersh#14)

possible improvements: move to ansi-terminal or other couloring library in order to manage colours in a more scalable way (currently ANSI Escape codes are used)
@chshersh chshersh removed the hacktoberfest https://hacktoberfest.com/ label Feb 28, 2023
@martinhelmer
Copy link
Collaborator

martinhelmer commented Mar 23, 2023

how should the function behave if "Ask" is combined with NonInteractive? I would say that the sensible default is to NOT overwrite.
Also, what's the response to "overwrite? NO" ? throw an exception?

Edit:
To access the Interactive setting the function would need to run within the App context though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
No open projects
Status: Todo
Development

No branches or pull requests

2 participants