Skip to content

Commit b10263e

Browse files
committed
feat(cli): add --token option to self update command
Signed-off-by: Frost Ming <[email protected]>
1 parent 77d278f commit b10263e

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

crates/uv-cli/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ pub enum SelfCommand {
427427
pub struct SelfUpdateArgs {
428428
/// Update to the specified version. If not provided, uv will update to the latest version.
429429
pub target_version: Option<String>,
430+
431+
/// Specify a github token for authentication during the update process.
432+
#[arg(long, env = "UV_GITHUB_TOKEN")]
433+
pub token: Option<String>,
430434
}
431435

432436
#[derive(Args)]

crates/uv/src/commands/self_update.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ use crate::commands::ExitStatus;
1111
use crate::printer::Printer;
1212

1313
/// Attempt to update the uv binary.
14-
pub(crate) async fn self_update(version: Option<String>, printer: Printer) -> Result<ExitStatus> {
14+
pub(crate) async fn self_update(version: Option<String>, token: Option<String>, printer: Printer) -> Result<ExitStatus> {
1515
let mut updater = AxoUpdater::new_for("uv");
1616
updater.disable_installer_output();
1717

18+
if let Some(token) = token {
19+
updater.set_github_token(&token);
20+
}
21+
1822
// Load the "install receipt" for the current binary. If the receipt is not found, then
1923
// uv was likely installed via a package manager.
2024
let Ok(updater) = updater.load_receipt() else {

crates/uv/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
766766
}
767767
#[cfg(feature = "self-update")]
768768
Commands::Self_(SelfNamespace {
769-
command: SelfCommand::Update(SelfUpdateArgs { target_version }),
770-
}) => commands::self_update(target_version, printer).await,
769+
command: SelfCommand::Update(SelfUpdateArgs { target_version, token }),
770+
}) => commands::self_update(target_version, token, printer).await,
771771
Commands::Version { output_format } => {
772772
commands::version(output_format, &mut stdout())?;
773773
Ok(ExitStatus::Success)

0 commit comments

Comments
 (0)