Skip to main content
build status Latest Released Version Supported Python Versions License

tinyprompt

A tiny lib for nice, handy prompts, primarily for Ops scripts.

This README contains all documentation.

Usage

pip install tinyprompt

Use tinyprompt.skippable to wrap script steps with a Yes / Skip / Quit prompt. This is very useful for simple scripted operations where - yes is the normal case - skip can be used to resume after a failure or abort - quit is used to abort when issues are encountered

import tinyprompt

# note: tinyprompt.skippable passes arguments through verbatim, but it's
# not guaranteed to return a meaningful result
# `quit` does a sys.exit(1) and `skip` makes it return `None`

@tinyprompt.skippable('skippable script step')
def my_func():
    """
    Do some things, this docstring will show up as a command description
    when the script is run.
    The "skippable script step" arg will be uppercased and used as the step
    name.
    """
    print('this skippable step')


@tinyprompt.skippable('other skippable script step', color=False)
def my_func2():
    """another func"""
    print('hi')


def otherfunc():
    # yes, it's on purpose
    tinyprompt.color_print('red string', tinyprompt.RED)
    tinyprompt.color_print('yellow string', tinyprompt.BLUE)
    tinyprompt.color_print('green string', tinyprompt.GRAY)
    tinyprompt.color_print('blue string', tinyprompt.GREEN)
    tinyprompt.color_print('gray  string', tinyprompt.YELLOW)


def main():
    my_func()  # skippable
    my_func2()  # skippable
    otherfunc()  # not skippable, but not reached on quit

if __name__ == '__main__':
    main()

Contributing

  • All code must pass make test

  • All code is autoformatted with black and isort

  • Try to write a test whenever you find a bug

  • Make your PRs clean. Rebase to avoid merge conflicts and squash fixup commits

Release files for tinyprompt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tinyprompt 0.1.0
File Size Uploaded
tinyprompt-0.1.0.tar.gz 4.2 kB Details

Release files / tinyprompt-0.1.0.tar.gz

Download URL tinyprompt-0.1.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cfa6a67b9f31e3a745f262317814b7701cedfd60d4459b17e1b84fbfbba10f6c
BLAKE2b-256 checksum
How to use checksums
56ed7685ecf5e549536df8a18ea6c3a889835bcd7e391fcc1d056499828d4a31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page