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 details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: puissant-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for puissant-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57651666866167e84bfc150a65a5b14d0b884ba7cb0424c4d0796296a2abdd77
MD5 49bc8a653a9909f7f6dce5ec483f4048
BLAKE2b-256 0b3426efb8b035dee5d008a48baa96e7f181f1f0004092ecc823557686de0a35

See more details on using hashes here.

File details

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

File metadata

  • Download URL: puissant-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for puissant-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e48007cb81464771f08d84053753cb53d6c67f06b6bfb48e00ce243a23ab4fc6
MD5 7b99fc677ad71167769da0f8f1ce9f36
BLAKE2b-256 0b82368d8052086dd0b774a86fba5dd451b9882a546a7007c01430546843e919

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