Overview

Promptly -

A Python package for providing feedback and interaction from the command line

Prompts

  • boolean_prompt (y/N)
  • string prompt
  • numeric prompt
  • menu/choice prompt

prompts user and reads user response

validates user response

if response invalid?

  • prompt user again?
  • fail and bail out?
  • allow developer to decide!

Info

Prints a message and waits for user to acknowledge (e.g. by hitting 'Enter')

StatusLine

Use StatusLine objects to create lines similar to this:

s = promptly.StatusLine('Some Text Here', success='OK').write()

This gives output like:

  • Some Text Here [OK]

You can also use status objects as context managers:

with promptly.StatusLine('Message', success='OK', failure='FAIL', warning='WARN'):
# do stuff here

Progress

p = promptly.Progess(100) p.update(20) p.display()

keeps track of a current and a total (e.g. amount of file read &total file size)

automatically calculates percentage done, and formats output

gives output like:

blahblah [====> ] 20%

Spinner

uses sequence: [|/-]

maybe as context mgr also?

Throbber

like the spinner but uses the sequence: [.o0o]

Future plans

Colorize output? (making this portable across Unix/Win32 might be tricky)