From beacf4fb2d9085529137336e34e6cefbc39bf7c6 Mon Sep 17 00:00:00 2001 From: benexl Date: Wed, 31 Dec 2025 19:54:45 +0300 Subject: [PATCH] feat: add command to clear cached GitHub authentication token --- viu_media/cli/commands/config.py | 16 +++++++++++++++- viu_media/cli/service/github/service.py | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/viu_media/cli/commands/config.py b/viu_media/cli/commands/config.py index 8be3a30..7fe080a 100644 --- a/viu_media/cli/commands/config.py +++ b/viu_media/cli/commands/config.py @@ -30,6 +30,9 @@ from ...core.config import AppConfig \b # view the current contents of your config viu config --view +\b + # clear cached GitHub authentication token + viu config --clear-github-auth """, ) @click.option("--path", "-p", help="Print the config location and exit", is_flag=True) @@ -60,6 +63,11 @@ from ...core.config import AppConfig is_flag=True, help="Start the interactive configuration wizard.", ) +@click.option( + "--clear-github-auth", + is_flag=True, + help="Clear cached GitHub authentication token.", +) @click.pass_obj def config( user_config: AppConfig, @@ -69,12 +77,18 @@ def config( generate_desktop_entry, update, interactive, + clear_github_auth, ): from ...core.constants import USER_CONFIG from ..config.editor import InteractiveConfigEditor from ..config.generate import generate_config_toml_from_app_model - if path: + if clear_github_auth: + from ..service.github import GitHubContributionService + + GitHubContributionService.clear_cached_auth_static() + click.echo("GitHub authentication cache cleared.") + elif path: print(USER_CONFIG) elif view: from rich.console import Console diff --git a/viu_media/cli/service/github/service.py b/viu_media/cli/service/github/service.py index 6ade4e9..570770d 100644 --- a/viu_media/cli/service/github/service.py +++ b/viu_media/cli/service/github/service.py @@ -645,6 +645,13 @@ This PR updates `{NORMALIZER_FILE_PATH}` with the following mapping: AUTH_FILE.unlink() logger.info("Cleared GitHub authentication cache") + @staticmethod + def clear_cached_auth_static() -> None: + """Clear cached GitHub authentication (static method for CLI use).""" + if AUTH_FILE.exists(): + AUTH_FILE.unlink() + logger.info("Cleared GitHub authentication cache") + def _log_info(self, message: str) -> None: """Log info message.""" if self.feedback: