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

Add a --output and -o flag to uv export #7058

Closed
SamEdwardes opened this issue Sep 5, 2024 · 8 comments · Fixed by #7109
Closed

Add a --output and -o flag to uv export #7058

SamEdwardes opened this issue Sep 5, 2024 · 8 comments · Fixed by #7109
Assignees
Labels
cli Related to the command line interface enhancement New feature or improvement to existing functionality good first issue Good for newcomers

Comments

@SamEdwardes
Copy link

Background

Thank you for adding the uv export command. It is a great feature. One improvement that would be helpful is to include an option to export the data to a file. For example, currently you can do this:

uv export > requirements.txt

However, it would be a nice feature to have an output flag. For example:

uv export --output requirements.txt
# or...
uv export -o requirements.txt

This is the same approach that poetry uses: https://python-poetry.org/docs/cli/#export

Why

Using > or >> requires the user to have more advanced shell knowledge. Having an output flag could be easier for users.

System

❯ uv --version
uv 0.4.5 (42b6bfbad 2024-09-04)
@zanieb zanieb added enhancement New feature or improvement to existing functionality cli Related to the command line interface labels Sep 5, 2024
@zanieb
Copy link
Member

zanieb commented Sep 5, 2024

We can also do an atomic write with this.

@zanieb
Copy link
Member

zanieb commented Sep 5, 2024

Also needed for astral-sh/uv-pre-commit#16

@charliermarsh
Copy link
Member

Why is it needed there vs. piping the output? Just curious.

@zanieb
Copy link
Member

zanieb commented Sep 5, 2024

I think so users can customize the file name via args:? (mostly echoing the chat there)

@SamEdwardes
Copy link
Author

Why is it needed there vs. piping the output? Just curious.

It is definitely not needed. But I think it is a nice to have:

@charliermarsh
Copy link
Member

I will do this quickly.

@SamEdwardes
Copy link
Author

Awesome thank you Charlie!

@FishAlchemist
Copy link
Contributor

Why is it needed there vs. piping the output? Just curious.

I think this feature is necessary, mainly due to text encoding issues. UV writes files would allow us to unify text encoding. If we use piped output, the encoding would depend on the settings or defaults, just like how PowerShell has different encoding behaviors.

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-7.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command line interface enhancement New feature or improvement to existing functionality good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants