Skip to main content

Have a nice looking, simple cli in seconds

Project description

cliasi (cli easy)

Output pretty command line text without hassle.
This is mostly a collection of pretty print commands

By using colorama, the text you see below is colored nicely.

Basic Usage

from cliasi import cli

cli.success("It works!")
# > ✔ [CLI] | It works!

cli.oneline = True
# The next few lines will get overwritten
cli.info("blah")
cli.warn("doing something dangerous")
# > ! [CLI] | doing something dangerous

# You can even ask for input and the input will disappear
cli.log("Got input: " + cli.ask("Give input: "))
# > LOG [CLI] | Got input: test

Prefix and Cliasi instances

Sometimes you might want to indicate different parts of your program working.
You can do that by having another instance of Cliasi with another prefix

from cliasi import cli, Cliasi  # Default shared Cliasi instance

cli.update_prefix("MANAGE")
cli.fail("Management failed")
# > X [MANAGE] | Management failed

def calculate():
    # Another part of your program could have its own instance
    clisi = Cliasi("CALC", use_oneline=True)
    clisi.info("Calculating...")
    # > i [CALC] | Calculating...
    # Although it might be better to use other methods for waiting

Animations

Some processes might take a few seconds to complete and you dont know how much the process is done (you cant use a progress bar)
In that case you can use either a blocking or non blocking animate method.

from cliasi import cli

# This will wait for three seconds and display an animation
cli.animate_message_blocking("Saving files, press CRTL-C to stop", 3)
save_data()

# But if you want to wait for something to finish and display something nice in the meantime
task = cli.animate_message_non_blocking("Waiting for a process to quit")
# Put your processing logic here
do_stuff_that_takes_time()
task.stop()  # Stop the animation
cli.success("Process quit")

Progress Bars

You can also have a progress bar which adapts to the size of your terminal
There are static versions which you just call every time you have an update and animated versions.

from cliasi import cli

processed, total = 0, len(calculate_queue)
while not calculate_queue.is_empty():
    cli.progressbar("Calculating items...", processed / total)
    calculate_next_item()
    processed += 1

cli.success("Calculation complete")
# This will show a progress bar that will only update when a calculation has finished.
# Potentially bad if it gets stuck on a calculation

images will appear here at some point

from cliasi import cli

task = cli.progressbar_animated_download("Downloading files.")
download()
task.update(10)
# You can also change the message while in the process
task.message = "Extracting"
extract()
task.update(40)
extract_again()

task.stop()

Project details


Download files

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

Source Distribution

cliasi-0.1.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

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

cliasi-0.1.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cliasi-0.1.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for cliasi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d9326b3f4ede7113b3125d34ee2d1dbe7128796c95e98ad92d244d2ddbe0d585
MD5 dc00d42fcae82598fc6dd49301bc593d
BLAKE2b-256 fec2f5061ce47ebb68241840c5735dcb0473f24bcad907fdf08d405ec28cec4e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cliasi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for cliasi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 361d3a6d87711184ac685d134c11648fde7791b05dea62575a64d99da4ddea28
MD5 f35e53d5244af84e4939f599e1778154
BLAKE2b-256 7904a9baa58149050c0c181eaa061df8129344d1fd280bb77a5ffc779ba494d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page