Skip to content

your-tools/python-cli-ui

Repository files navigation

https://img.shields.io/badge/deps%20scanning-pyup.io-green

python-cli-ui

Tools for nice user interfaces in the terminal.

Note

This project was originally hosted on the TankerHQ organization, which was my employer from 2016 to 2021. They kindly agreed to give back ownership of this project to me. Thanks!

Documentation

See python-cli-ui documentation.

Demo

Watch the asciinema recording.

Usage

$ pip install cli-ui

Example:

import cli_ui

# coloring:
cli_ui.info(
  "This is",
  cli_ui.red, "red", cli_ui.reset,
  "and this is",
  cli_ui.bold, "bold"
)

# enumerating:
list_of_things = ["foo", "bar", "baz"]
for i, thing in enumerate(list_of_things):
    cli_ui.info_count(i, len(list_of_things), thing)

# progress indication:
cli_ui.info_progress("Done",  5, 20)
cli_ui.info_progress("Done", 10, 20)
cli_ui.info_progress("Done", 20, 20)

# reading user input:
with_sugar = cli_ui.ask_yes_no("With sugar?", default=False)

fruits = ["apple", "orange", "banana"]
selected_fruit = cli_ui.ask_choice("Choose a fruit", choices=fruits)

#  ... and more!

Contributing

We use optimistic merging so you don't have to worry too much about formatting the code, pleasing the linters or making sure all the test pass.

That being said, if you want, you can install just and use it to check your changes automatically. Just run just to see available tasks.

Making a new release

  • Create a token on pypi : see pypi help for details.
  • Install tbump and use it to bump cli-ui to the new version.

Uploading documentation

Run:

just deploy-doc