fix rich autodetection of TTY, USE_COLOR, SHOW_PROGRESS

This commit is contained in:
Nick Sweeting 2024-09-24 19:37:29 -07:00
parent bde0bf8263
commit 0dffbf1bb4
No known key found for this signature in database
4 changed files with 32 additions and 17 deletions

View file

@ -2,7 +2,6 @@ __package__ = 'archivebox.misc'
# TODO: merge/dedupe this file with archivebox/logging_util.py
import os
import sys
from typing import Optional, Union, Tuple, List
from collections import defaultdict
@ -11,12 +10,10 @@ from rich.console import Console
from ..config_stubs import ConfigDict
SHOW_PROGRESS = None
if os.environ.get('SHOW_PROGRESS', 'None') in ('True', '1', 'true', 'yes'):
SHOW_PROGRESS = True
# SETUP RICH CONSOLE / TTY detection / COLOR / PROGRESS BARS
CONSOLE = Console()
IS_TTY = CONSOLE.is_interactive
CONSOLE = Console(force_interactive=SHOW_PROGRESS)
SHOW_PROGRESS = CONSOLE.is_interactive if SHOW_PROGRESS is None else SHOW_PROGRESS
DEFAULT_CLI_COLORS = benedict(
{