Skip to content

Comments

adding file.temp_file to eldritch#797

Merged
adm1nPanda merged 8 commits intomainfrom
eldritch-file-temp
Aug 15, 2024
Merged

adding file.temp_file to eldritch#797
adm1nPanda merged 8 commits intomainfrom
eldritch-file-temp

Conversation

@adm1nPanda
Copy link
Collaborator

What type of PR is this?

/feature
/kind eldritch-function

What this PR does / why we need it:

Implemented file.temp_file()

Which issue(s) this PR fixes:

Fixes #788

@adm1nPanda adm1nPanda requested a review from hulto August 6, 2024 04:37
Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops sorry @adm1nPanda i should have been more clear in the issue description.
For this feature we'd like to leverage the OSes default tmp system.
/tmp/ on linux, /var/private/tmp/*/*/* on mac, C:\Users\AppData\Local\Temp (i think) on Windows. You shouldn't need to specify the tmp dir path the library should handle that for you.

To do this we can leverage the temp file library we've been using and it looks like the .keep() call you're making is exactly what we need.

Instead of a random file name in a specified dir i'd like to create a tmp file in and optionally specify the name of that file.

The file should be empty and the function should return the path to the newly created file.

Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Just a couple changes then should be good 🤌

Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified how to do optional parameters.

This way lets users do something like:

tmp_file = file.temp()
# - or -
name_tmp_file = file.temp("special_name.txt")

Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple nits that you can ignore if you want.
One small change please.

hulto
hulto previously approved these changes Aug 13, 2024
Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Some optional nits if you want but this looks good to me! 🙂

hulto
hulto previously approved these changes Aug 14, 2024
@adm1nPanda adm1nPanda merged commit 3008866 into main Aug 15, 2024
@adm1nPanda adm1nPanda deleted the eldritch-file-temp branch August 15, 2024 02:46
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.

Eldritch implementfile.tmp_file

2 participants