feat: 주요 CLI, 인증, 서비스 로직 및 문서 개선
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""Output helpers dedicated to auth/bot CLI flows."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from rich.console import Console
|
||||
|
||||
from app.cli.core.utils import render_output
|
||||
from app.core.security import mask_secret
|
||||
|
||||
|
||||
def mask_token_text(raw_token: str) -> str:
|
||||
return mask_secret(raw_token, prefix=6, suffix=4)
|
||||
|
||||
|
||||
def _mask_payload(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
masked = dict(payload)
|
||||
token = masked.get("token")
|
||||
if isinstance(token, str) and token:
|
||||
masked["token"] = mask_token_text(token)
|
||||
return masked
|
||||
|
||||
|
||||
def render_bot_result(console: Console, output_format: str, payload: Any) -> None:
|
||||
plain = payload.model_dump(mode="json") if hasattr(payload, "model_dump") else payload
|
||||
if isinstance(plain, dict):
|
||||
render_output(console, output_format, _mask_payload(plain))
|
||||
return
|
||||
render_output(console, output_format, plain)
|
||||
Reference in New Issue
Block a user