Skip to content

topmark.cli.console.standard_console

topmark / cli / console / standard_console

Stdlib-based console implementation used outside Click contexts.

StdConsole

StdConsole(*, enable_color=False, out=None, err=None)

Bases: ConsoleProtocol

Simple console implementation backed by stdlib text streams.

Parameters:

Name Type Description Default
enable_color bool

Ignored for this implementation. Present only to keep the constructor shape aligned with the Click-backed console.

False
out TextIO | None

Stream for normal output. Defaults to sys.stdout.

None
err TextIO | None

Stream for warning/error output. Defaults to sys.stderr.

None
Source code in src/topmark/cli/console/standard_console.py
def __init__(
    self, *, enable_color: bool = False, out: TextIO | None = None, err: TextIO | None = None
) -> None:
    self.enable_color: bool = enable_color
    self.out: TextIO = out or sys.stdout
    self.err: TextIO = err or sys.stderr

print

print(text='', *, nl=True)

Write a message to stdout.

Source code in src/topmark/cli/console/standard_console.py
def print(self, text: str = "", *, nl: bool = True) -> None:
    """Write a message to stdout."""
    self.out.write(text + ("\n" if nl else ""))

warn

warn(text, *, nl=True)

Write a warning message to stderr.

Source code in src/topmark/cli/console/standard_console.py
def warn(self, text: str, *, nl: bool = True) -> None:
    """Write a warning message to stderr."""
    self.err.write(text + ("\n" if nl else ""))

error

error(text, *, nl=True)

Write an error message to stderr.

Source code in src/topmark/cli/console/standard_console.py
def error(self, text: str, *, nl: bool = True) -> None:
    """Write an error message to stderr."""
    self.err.write(text + ("\n" if nl else ""))