CLI UI

0.19.0 · active · verified Thu Apr 16

cli-ui is a Python library designed to help developers build aesthetically pleasing and user-friendly command-line interfaces. It provides tools for informative messages, error messages, progress indicators, formatting, and interactive user input (e.g., yes/no questions, choices). The current version is 0.19.0, and the project appears to be actively maintained, with recent updates and continued development on its GitHub repository.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates common usage patterns for `cli-ui`, including printing colored messages, showing progress, and gathering user input through yes/no questions and choice selections.

import ui

# Informative messages
ui.info("This is", ui.green, "green", ui.reset, "text.")
ui.info_2("Starting", "Process X...")

# Progress indication
list_of_items = [f"Item {i}" for i in range(1, 6)]
for i, item in enumerate(list_of_items):
    ui.info_count(i, len(list_of_items), f"Processing {item}")

# User input
with_confirmation = ui.ask_yes_no("Proceed with action?", default=True)
if with_confirmation:
    fruits = ["apple", "orange", "banana"]
    selected_fruit = ui.ask_choice("Choose a fruit", choices=fruits)
    ui.info(f"You selected: {selected_fruit}")
else:
    ui.info("Action cancelled.")

view raw JSON →