Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!
Features
Installation
Quick Start
API Overview
Colors and Formatting
Available colors:
black,red,green,yellow,blue,magenta,cyan,whiteAvailable formatting:
bold,faint,standout,underline,blink,overline,resetInformation Functions
info(*tokens, **kwargs)- Print informative messageinfo_1(*tokens, **kwargs)- Important info with "::" prefixinfo_2(*tokens, **kwargs)- Secondary info with "=>" prefixinfo_3(*tokens, **kwargs)- Detailed info with "*" prefixinfo_section(*tokens, **kwargs)- Section header with underlinedebug(*tokens, **kwargs)- Debug message (only shown if verbose=True)Error Functions
warning(*tokens, **kwargs)- Print warning messageerror(*tokens, **kwargs)- Print error messagefatal(*tokens, exit_code=1, **kwargs)- Print error and exitProgress Functions
dot(last=False, fileobj=sys.stdout)- Print progress dotinfo_count(i, n, *rest, **kwargs)- Show counter with messageinfo_progress(prefix, value, max_value)- Show percentage progressUser Input Functions
ask_string(*question, default=None)- Ask for string inputask_password(*question)- Ask for password (hidden input)ask_yes_no(*question, default=False)- Ask yes/no questionask_choice(*prompt, choices, func_desc=None, sort=True)- Choose from listselect_choices(*prompt, choices, func_desc=None, sort=True)- Select multipleTable Functions
info_table(data, headers=(), fileobj=sys.stdout)- Display formatted tableUtility Functions
indent(text, num=2)- Indent text by number of spacestabs(num)- Generate tab spacingdid_you_mean(message, user_input, choices)- Suggest correctionsConfiguration
Timer Context Manager
Testing Support
For testing code that uses cli-ui:
Examples
See the
examples/directory for:Requirements
License
BSD 3-Clause License. See LICENSE file for details.
Contributing
Contributions welcome! Please see the contributing guidelines in the repository.