From 63d575ca28e711931eaea4714a5776aa722648a6 Mon Sep 17 00:00:00 2001 From: ste Date: Sat, 10 Feb 2024 10:51:46 +0100 Subject: [PATCH] Move ratelimit message to error Section --- src/commands/upgrade.rs | 12 ++++++++++-- src/main.rs | 6 +----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/commands/upgrade.rs b/src/commands/upgrade.rs index ddc7f75..f30c429 100644 --- a/src/commands/upgrade.rs +++ b/src/commands/upgrade.rs @@ -1,5 +1,6 @@ use clap::Args; use color_eyre::eyre::{Result, WrapErr}; +use color_eyre::Section; use inquire::Select; use self_update::{ backends::github::{ReleaseList, Update}, @@ -33,7 +34,10 @@ impl Upgrade { let raw_releases = releases_cfg .build()? .fetch() - .wrap_err("Unable to fetch list of releases")?; + .wrap_err("Unable to fetch list of releases") + .with_suggestion(|| { + "If ratelimited: export GITHUB_TOKEN='insert_token_here'" + })?; let releases = raw_releases .iter() @@ -67,7 +71,11 @@ impl Upgrade { cfg = cfg.auth_token(&token); } - let _ = cfg.build()?.update()?; + let _ = cfg + .build()? + .update() + .with_suggestion(|| "If ratelimited: export GITHUB_TOKEN='insert_token_here'"); + Ok(String::default()) }) .join() diff --git a/src/main.rs b/src/main.rs index 6af7611..229655d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,11 +53,7 @@ enum Commands { #[cfg(debug_assertions)] Query(Query), /// Download and install latest version - #[command( - visible_alias = "u", - alias = "update", - after_help = "Ratelimit fix: export GITHUB_TOKEN='insert token here'" - )] + #[command(visible_alias = "u", alias = "update")] Upgrade(Upgrade), }