Awesome CLI input and output functions for Python 3.x scripts.
Project description
cli-fragments
Awesome terminal input and output functions for Python 3.x scripts.
Why this name?
I like to consider the command-line interface as if it were a graphical interface. In the development of graphical interfaces, 'components' are usually used to facilitate maintainability and design consistency. In my opinion, the word 'fragments' is a correct synonym to describe the same approach, but for command-line interfaces.
Fragments
error
: a red message having[✕]
as prefixsuccess
: a green message having[✓]
as prefixwarning
: a yellow message having[!]
as prefixtext
: a standard text in terminal having the proper paddingdebug
: a default color message having[#]
as prefixnotice
: a blue message having[~]
as prefixask
: a qustion to the user having[?]
as prefix. The input value can be optionally validated passing avalidator
callback
Usage
pip install cli-fragments
from cli_fragments import CliFragments
def validator_function(value: str):
if value == "wrong":
raise ValueError
io = CliFragments()
io.debug("This is a debug message.")
io.notice("This is a notice message.")
io.warning("This is a warning message.")
io.error("This is an error message.")
io.success("This is a success message.")
io.text("This is padded raw text message.")
io.ask("This is a user question.", None, None)
io.ask("This is a user question.", "default", validator_function)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cli_fragments-1.1.0.tar.gz
(14.6 kB
view hashes)
Built Distribution
Close
Hashes for cli_fragments-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c492cafcb308e7d860b3e545bf0c046f619f348dabc7e1e8ac4444b53bb7fcc |
|
MD5 | d00a474ba9e6e8e043ec699df419df23 |
|
BLAKE2b-256 | 3585e9eccea8a468e96badd3855b0125986bdf967076c0e045d0b1f2eafbb898 |