Skip to main content

nice and simple command line output

Project description

opsis

Nice and simple command-line output for Python. Fka comms

Note: This package is experimental — the API may change between releases.

What is this?

opsis gives you a clean, consistent way to print structured output from CLI applications. It handles the fiddly bits — column alignment, truncation, spinners, timing — so you can focus on what your tool actually does.

It's particularly useful for scripts and tools that perform a sequence of discrete tasks (parsing files, calling APIs, running checks, etc.) where you want to show progress without cluttering the terminal.

Install

pip install opsis

Quick start

from opsis import Comms

comms = Comms(prefix="myapp")

comms.announce("Starting up")
comms.talk("Processing input files...")
comms.warn("Something looks off!")

This produces neatly aligned, prefixed output like:

[myapp]         Starting up
[myapp]         -> Processing input files...
[myapp]         ** Something looks off!

Features

Messages

comms.talk("Regular message")           # prefixed, indented with ->
comms.announce("Important heading")     # bold, followed by a blank line
comms.warn("Something went wrong")      # bold red, indented with **

Multi-line messages

Print structured, multi-line output with an optional boldened title:

comms.state("Line one\nLine two\nLine three", title="Results")
comms.state(["Also works", "with lists"])

Reporter

For multi-step operations, use a Reporter. It manages tasks, steps, timing, and animated spinners for you:

reporter = comms.reporter()

reporter.start("building project")       # begins a timed task
reporter.step("compiling sources")       # shows a spinner while waiting
# ... do work ...
reporter.step("linking binaries")        # finishes previous step, starts next
# ... do work ...
reporter.done()                          # prints completion with elapsed time

Each step is automatically timed. While a step is running, a spinner animates in-place. When the next step starts (or done() is called), the previous step's duration is printed:

[myapp]         start building project ...
[myapp]         .. compiling sources                              ✓ (1.203s)
[myapp]         .. linking binaries                               ✓ (0.042s)
[myapp]         done building project!                            ✓ (1.245s)

For fast, repetitive operations, use a ticker instead of a spinner:

reporter.step("processing files", spin=False)
for i, path in enumerate(files):
    process(path)
    reporter.tick(f"file {i}")           # updates in-place, throttled

You can still use comms.talk() and comms.warn() during a reporter session — they print cleanly without disrupting the spinner.

Custom prefix

Every Comms instance takes a prefix that appears in brackets on each line. Use this to identify your tool:

comms = Comms(prefix="deploy")
# [deploy]        -> uploading artifacts...

TTY detection

Spinners and tickers are automatically disabled when stdout is not a TTY (e.g. when piping to a file or running in CI). Your output stays clean and parseable without any extra configuration.

Dependencies

Just click (for styled terminal output).

License

MIT

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

opsis-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

opsis-0.1.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file opsis-0.1.1.tar.gz.

File metadata

  • Download URL: opsis-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for opsis-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4c8f23955f5c03e704e0c53fa01727127113b170b5088d221006275f3c6970f2
MD5 fd9d75902280993ab8178eb00ddc6a8b
BLAKE2b-256 c09695864f71e29e3559d16326b2cdd2be058cba86a6490c15c805943629b006

See more details on using hashes here.

Provenance

The following attestation bundles were made for opsis-0.1.1.tar.gz:

Publisher: release.yml on sirmarcel/opsis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opsis-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: opsis-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for opsis-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c670da7b116526d605030cdd835818ddb32f90895bc7a2ced5b3be65a1b76fbf
MD5 f2f74dce660148f47279fa81ff501590
BLAKE2b-256 41cc95cb2cb9a56dae85751cd637194d826878dcbb821c06e90c5580dfbe1532

See more details on using hashes here.

Provenance

The following attestation bundles were made for opsis-0.1.1-py3-none-any.whl:

Publisher: release.yml on sirmarcel/opsis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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