Skip to main content

validated python command line user input

Project description

validated user input over command line the easy way

puissant is a collection of Python functions to implement validated user input from command line

Dependencies

  • Python version required: 3.7+

  • If documentation is to be generated sphinx and sphinx_rtd_theme packages are required:

pip install sphinx sphinx_rtd_theme

Installation

Simply type

pip install puissant

Documentation

Documentation can be found @ readthedocs

Examples

  • yes/no question

>>> from  puissant import *
>>> yes_no(prompt = "Are you happy")
Are you happy [y/n]?maybe
 input must be one of y, n, yes, no.
Are you happy [y/n]?yes
True
  • yes/no question with default value

>>> yes_no(prompt = "Are you happy", default = 'y')
Are you happy [y/n]?(default:y) True
  • Single option menu:

>>> menu(prompt = 'what next?', options = ['restart', 'continue', 'quit'])
what next?
 1 - restart
 2 - continue
 3 - quit
select an item [range: 1..3]: 4
input must be in range 1..3.
select an item [range: 1..3]: quit
input must be of type int.
select an item [range: 1..3]: 1
'restart'
  • Tickbox (multiple selection) menu:

>>> tickbox_menu('add extras', ['mayo', 'ketchup', 'garlic', 'tabasco'])
add extras
1  [ ] - mayo
2  [ ] - ketchup
3  [ ] - garlic
4  [ ] - tabasco

- type a number to tick the option.
- "a" selects all.
- "n" de-selects all.
- "d" selection done.

Option? : 1
add extras
1  [x] - mayo
2  [ ] - ketchup
3  [ ] - garlic
4  [ ] - tabasco

- type a number to tick the option.
- "a" selects all.
- "n" de-selects all.
- "d" selection done.

Option? : 3
add extras
1  [x] - mayo
2  [ ] - ketchup
3  [x] - garlic
4  [ ] - tabasco

- type a number to tick the option.
- "a" selects all.
- "n" de-selects all.
- "d" selection done.

Option? : d
[(0, 'mayo'), (2, 'garlic')]

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

puissant-0.1.0.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

puissant-0.1.0-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

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