feat(cli): add --token option to self update command (#7279)

<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

It often reaches the GitHub API rate limit and shows error like `error:
HTTP status client error (403 Forbidden) for url
(https://api.github.com/repos/astral-sh/uv/releases)` when running `uv
self update`.

To bypass this rate limit issue, allow user to pass a GitHub token via
`--token` or `UV_GITHUB_TOKEN` env.

## Test Plan

<!-- How was it tested? -->

---------

Signed-off-by: Frost Ming <me@frostming.com>
This commit is contained in:
Frost Ming
2024-09-13 03:27:54 +08:00
committed by GitHub
parent 3d2b94f0b0
commit e1e85ab4c8
5 changed files with 40 additions and 7 deletions
+5
View File
@@ -427,6 +427,11 @@ pub enum SelfCommand {
pub struct SelfUpdateArgs {
/// Update to the specified version. If not provided, uv will update to the latest version.
pub target_version: Option<String>,
/// A GitHub token for authentication.
/// A token is not required but can be used to reduce the chance of encountering rate limits.
#[arg(long, env = "UV_GITHUB_TOKEN")]
pub token: Option<String>,
}
#[derive(Args)]