Use shared ANSI stripping in Hermes Console

This commit is contained in:
Shannon Sands 2026-07-03 10:50:56 +10:00 committed by kshitij
parent f7d90edd8b
commit 1e7111d25d
2 changed files with 34 additions and 9 deletions

View file

@ -9,11 +9,10 @@ from __future__ import annotations
import argparse
import contextlib
import importlib
import difflib
import importlib
import io
import json
import re
import shlex
import sys
from dataclasses import dataclass, replace
@ -21,6 +20,8 @@ from pathlib import Path
from typing import Callable, Iterable, Literal, NoReturn, Sequence
from urllib.parse import urlparse
from tools.ansi_strip import strip_ansi as _strip_ansi
ConsoleStatus = Literal["ok", "error", "confirm_required", "exit", "clear"]
ConsoleContext = Literal["local", "hosted"]
@ -73,13 +74,6 @@ def _capture_output(fn: Callable[[], object]) -> str:
return text.rstrip()
_ANSI_RE = re.compile(r"\x1b\[[0-?]*[ -/]*[@-~]")
def _strip_ansi(text: str) -> str:
return _ANSI_RE.sub("", text)
def _is_status_footer_rule(line: str) -> bool:
stripped = _strip_ansi(line).strip()
if len(stripped) < 8: