feat: add service token rename command (#40)

* docs: preserve original issue 5 body

* feat: add service token rename command

* test: normalize rich option errors
This commit is contained in:
2026-09-19 21:19:39 +09:00
committed by GitHub
parent 996127f215
commit deaaa96c46
20 changed files with 882 additions and 7 deletions
+33 -1
View File
@@ -8,7 +8,13 @@ import typer
from app.cli.core.output import mask_token_text, render_service_token_result
from app.cli.core.utils import render_output
from app.schemas.auth import AuthTokenResponse, ServiceTokenIssueCliResponse, ServiceTokenRebindCliResponse, ServiceTokenRevokeCliResponse
from app.schemas.auth import (
AuthTokenResponse,
ServiceTokenIssueCliResponse,
ServiceTokenRebindCliResponse,
ServiceTokenRenameCliResponse,
ServiceTokenRevokeCliResponse,
)
from app.services.auth_service import AuthService
token_app = typer.Typer(help="Service token lifecycle commands.")
@@ -92,6 +98,32 @@ def issue_service_token(
ctx.obj.console.print("[yellow]⚠ 이 토큰은 다시 표시되지 않습니다. 지금 복사해 안전한 곳에 저장하세요.[/yellow]")
@token_app.command("rename")
def rename_service_token(
ctx: typer.Context,
name: str = typer.Argument(..., help="Active service token name to rename."),
new_name: str = typer.Option(..., "--new-name", help="New unique service token name."),
force: bool = typer.Option(False, "--force", "-f", help="Skip confirmation prompt."),
) -> None:
"""Rename an active service token without rotating its bearer token."""
if not force:
confirmed = typer.confirm(f"서비스 토큰 이름을 '{name}'에서 '{new_name}'(으)로 변경하시겠습니까?")
if not confirmed:
raise typer.Exit(code=0)
def _rename(service: AuthService, app_context):
return service.rename_service_token(name, new_name)
renamed = _with_service(ctx, _rename)
response = ServiceTokenRenameCliResponse(
token_id=renamed.auth_token.id,
old_name=name,
new_name=renamed.auth_token.name,
changed=renamed.changed,
)
render_service_token_result(ctx.obj.console, ctx.obj.output_format, response)
@token_app.command("rotate")
def rotate_service_token(
ctx: typer.Context,