Skip to content

Prevent cobra from overwriting files by default#68

Closed
larsks wants to merge 3 commits into
spf13:mainfrom
larsks:feature/no-overwrite
Closed

Prevent cobra from overwriting files by default#68
larsks wants to merge 3 commits into
spf13:mainfrom
larsks:feature/no-overwrite

Conversation

@larsks

@larsks larsks commented Feb 3, 2023

Copy link
Copy Markdown

Running cobra-cli init or cobra-cli add would overwrite existing files without warning, which could result in unexpected loss of data. This commit modifies cobra-cli so that by default it will not overwrite files, and adds the --force flag to the init and add subcommands to allow it to overwrite files.

Closes #59

@CLAassistant

CLAassistant commented Feb 3, 2023

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

The cmd/ tests compared generated output to static data stored in
cmd/testdata. The static data included the year, so each year the static
files must be updated or the test fails.

This commit treats the "golden" files as a template and substitutes the
year before making the comparison.
Running `cobra-cli init` or `cobra-cli add` would overwrite existing
files without warning, which could result in unexpected loss of data.
This commit modifies cobra-cli so that by default it will not
overwrite files, and adds the `--force` flag to the `init` and `add`
subcommands to allow it to overwrite files.

Closes spf13#59
Refactor cmd/init_test.go so that we can sanely run multiple tests,
and then add tests for the --force feature.
@larsks larsks force-pushed the feature/no-overwrite branch from f3e1d42 to 20e98e4 Compare February 3, 2023 17:03
@larsks

larsks commented Apr 3, 2023

Copy link
Copy Markdown
Author

@spf13 (et al?) just checking to see if anyone is interested in this PR. Cheers!

@larsks

larsks commented Apr 10, 2023

Copy link
Copy Markdown
Author

Looks like that's a "no".

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.

coba-cli overwrites existing main.go with no warning

2 participants