Skip to main content

vanta A lightweight Python toolkit for beautiful, structured CLI output.


Vanta provides a simple Console class for building clean command-line interfaces with:

  • Colored log messages
  • Timestamps
  • Cross-platform terminal clearing
  • Typed user input
  • Yes/no confirmation prompts
  • Optional color output
  • Optional automatic screen clearing

Installation

From source

Clone the repository:

pip install vanta

Then in your IDE:

from vanta import Console

Quick Start

import vanta

console = vanta.Console()

console.info("Hello, world!")
console.success("Operation completed.")
console.warning("Something might be wrong.")
console.error("Something went wrong.")
console.notice("Please take note.")

Example output:

[16:42:10] [INFO] Hello, world!
[16:42:10] [SUCCESS] Operation completed.
[16:42:10] [WARNING] Something might be wrong.
[16:42:10] [ERROR] Something went wrong.
[16:42:10] [NOTICE] Please take note.

When colors are enabled, each message type is displayed with its own color.


Console

Create a console instance with:

console = vanta.Console()

By default, Vanta:

  • Enables colors
  • Clears the terminal when the console is created

Both behaviors can be configured:

console = vanta.Console(
    color=False,
    cls=False,
)

Parameters

Parameter Type Default Description
color bool True Enable or disable colored output
cls bool True Clear the terminal when initialized

Logging

Vanta provides five message variants.

Info

console.info("This is an informational message.")

Success

console.success("Everything went well!")

Warning

console.warning("Be careful.")

Error

console.error("Something went wrong.")

Notice

console.notice("Please take note of this.")

All messages include a timestamp.


Raw Output

Use raw() when you want to output a message without a variant prefix.

console.raw("Hello!")

By default, the timestamp is still displayed.

To remove the timestamp:

console.raw("Hello!", timestamp=False)

Output:

Hello!

Clearing the Terminal

The terminal can be cleared manually:

console.clear()

Vanta automatically uses the appropriate command for the operating system:

  • Windows: cmd /c cls
  • Linux/macOS: clear

User Input

The ask() method allows you to request and convert user input.

name = console.ask("What is your name:")

Since the default output type is str, this returns the entered text.

Integers

age = console.ask("How old are you:", int)

If the user enters:

18

age will be an int.

Invalid input is automatically rejected:

How old are you: abc
[16:45:21] [ERROR] Invalid. Please use int.
How old are you:

Floating-point numbers

price = console.ask("Enter the price:", float)

Custom converters

ask() accepts any callable that takes a str and returns the desired type.

For example:

def parse_name(value: str) -> str:
    value = value.strip()

    if not value:
        raise ValueError

    return value.title()


name = console.ask("Name:", parse_name)

Custom error messages

You can provide your own error message:

age = console.ask(
    "Age:",
    int,
    "Please enter a valid number."
)

Confirmation Prompts

Use confirm() for yes/no questions:

if console.confirm("Continue?"):
    print("Continuing...")

The default behavior is:

Continue? [Y/n]

Pressing Enter accepts the default (True).

Default to No

Set default=False:

if console.confirm("Delete this file?", default=False):
    print("Deleting...")

The prompt becomes:

Delete this file? [y/N]

Pressing Enter now returns False.

Accepted Answers

Yes:

y
1
ok
ye
yes
yep
yy

No:

n
0
no
nah
nn

Input is case-insensitive.

Custom Error Messages

console.confirm(
    "Continue?",
    error_message="Please answer with yes or no."
)

Disabling Colors

Colors can be disabled when creating the console:

console = vanta.Console(color=False)

Output will then use plain text:

[16:45:21] [INFO] Hello!

This can be useful when output is being redirected to a file or another program.


API Reference

Console

Console(
    color: bool = True,
    cls: bool = True
)

clear()

console.clear() -> None

Clears the terminal.

info()

console.info(message: str) -> None

Prints an informational message.

success()

console.success(message: str) -> None

Prints a success message.

warning()

console.warning(message: str) -> None

Prints a warning message.

error()

console.error(message: str) -> None

Prints an error message.

notice()

console.notice(message: str) -> None

Prints a notice message.

raw()

console.raw(
    message: str,
    timestamp: bool = True
) -> None

Prints unclassified output.

ask()

console.ask(
    question: str,
    output: Callable[[str], T] = str,
    error_message: str | None = None
) -> T

Prompts the user for input and converts it using output.

confirm()

console.confirm(
    question: str,
    error_message: str | None = None,
    default: bool = True
) -> bool

Prompts the user for a yes/no response.


Version

Current version: 0.1.0

Vanta is currently in early development. The API may change between releases before reaching a stable 1.0.0 release.

License

See LICENSE for license information.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vanta-0.1.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vanta-0.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file vanta-0.1.0.tar.gz.

File metadata

  • Download URL: vanta-0.1.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vanta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e91dae0d9d25854e6a0547a3a71370f2a3fde5be43948d52b9d4a6ac0670e46d
MD5 978c53b3f17b013aaf4e37b58034b694
BLAKE2b-256 5498960c56529d835718b0e2623fe7182e64f0c9149da3d0ee09724123bb1bb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for vanta-0.1.0.tar.gz:

Publisher: publish.yml on zscopuv/vanta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vanta-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vanta-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vanta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5010002ea55f8de44841bd1346b1924cb1f710e954a3d061022e63c8d0713e99
MD5 a0548832204fde97fca172c1c8daca22
BLAKE2b-256 9cd42b547a017a77dbfeb39c695c557750b58c94dda9b8c6aebf5eb70ac99a4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for vanta-0.1.0-py3-none-any.whl:

Publisher: publish.yml on zscopuv/vanta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page