Module materialize.terminal

Terminal utilities.

Expand source code Browse git
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.

"""Terminal utilities."""


COLOR_GREEN = "\033[92m"
COLOR_RED = "\033[91m"
COLOR_OK = COLOR_GREEN
COLOR_ERROR = COLOR_RED
STYLE_BOLD = "\033[1m"
_END_FORMATTING = "\033[0m"


def with_formatting(text: str, formatting: str) -> str:
    return with_formattings(text, [formatting])


def with_formattings(text: str, formattings: list[str]) -> str:
    formatting = "".join(formattings)
    return f"{formatting}{text}{_END_FORMATTING}"

Functions

def with_formatting(text: str, formatting: str) ‑> str
Expand source code Browse git
def with_formatting(text: str, formatting: str) -> str:
    return with_formattings(text, [formatting])
def with_formattings(text: str, formattings: list[str]) ‑> str
Expand source code Browse git
def with_formattings(text: str, formattings: list[str]) -> str:
    formatting = "".join(formattings)
    return f"{formatting}{text}{_END_FORMATTING}"