Skip to content

feat(scaffold): overwrite argument #63

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

Merged
merged 1 commit into from
Oct 31, 2024
Merged

feat(scaffold): overwrite argument #63

merged 1 commit into from
Oct 31, 2024

Conversation

AV3RG
Copy link
Contributor

@AV3RG AV3RG commented Feb 22, 2024

Solves #62

@fspoettel
Copy link
Owner

Hey @AV3RG, thanks for the PR. This looks like a good addition. Lmk once this is ready for review and I'll take a closer look.

@AV3RG
Copy link
Contributor Author

AV3RG commented Apr 12, 2024

Hey I just tested it and it works

The only change I could see that could be made is change the safe_create_file function to something like this

fn safe_create_file(path: &str, overwrite: bool) -> Result<File, std::io::Error> {
    let mut open_options = OpenOptions::new().write(true);
    if overwrite {
        open_options = open_options.create(true).truncate(true);
    } else {
        open_options = open_options.create_new(true);
    }
    open_options.open(path)
}

Or by using a match statement, otherwise it works

@AV3RG AV3RG marked this pull request as ready for review April 12, 2024 11:57
@fspoettel fspoettel merged commit 3657f8c into fspoettel:main Oct 31, 2024
@fspoettel
Copy link
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants