charmbracelet / freeze

Generate images of code and terminal output 📸
MIT License
3.24k stars 55 forks source link

feat: Include Confirmation dialogue if a file is about to be overwritten #86

Open prithvijj opened 5 months ago

prithvijj commented 5 months ago

Changes

Testing Notes

image

image

image

image

Other Notes

debdutdeb commented 5 months ago

I was going to look into adding this :+1: thanks !

maaslalani commented 5 months ago

Nice! I like this idea!

prithvijj commented 5 months ago

Changes:

go test -v ./...

image

but yeah, Lemme know if there's anything else missing

prithvijj commented 5 months ago

Changes:

Screenshot showing that a random directory is created beforehand and freeze is executed, which shows the overwrite confirmation form image

Providing input this-is-dir to show that it is overwriting to a directory image

Throws error indicating that it could not overwrite to the directory, which is expected image

pbj@pop-os:~/Github/freeze2$ mkdir this-is-dir
pbj@pop-os:~/Github/freeze2$ go run ./... --execute "cat SECURITY.md"

   ERROR  'this-is-dir' is a directory. Hence cannot overwrite to the given filename

  could not overwrite to filename

exit status 1

Looking for a re-review!

prithvijj commented 4 months ago

Just been having discussions on Discord Channel for #contributions, been a bit stale on my end, There was a good point made about figuring out if a flag could be introduced which overwrites the file in case no tty is recognized, and I've responded with it

Let's see what that looks like, shall keep the PR updated