Skip to main content

Commandline User Tools for Input Easification

Project description

CUTIE

Commandline User Tools for Input Easification

A tool for handling common user input functions in an elegant way so you don't have to write them yourself once a week.

example

Usage

These are the main functions of cutie:

import cutie

if cutie.prompt_yes_or_no('Are you brave enough to continue?'):
    names = [
        'Arthur, King of the Britons',
        'Sir Lancelot the Brave',
        'Sir Robin the Not-Quite-So-Brave-as-Sir-Lancelot',
        'Sir Bedevere the Wise',
        'Sir Galahad the Pure',
        'Møøse']
    name = names[cutie.select(names, selected_index=5)]
    print(f'Welcome, {name}')
    age = cutie.get_number(
        'What is your age?',
        min_value=0,
        allow_float=False)
    quest = cutie.secure_input('What is your quest?')
    print(f'{name}\'s quest (who is {age}) is {quest}.')
Are you brave enough to continue? (Y/N) Yes
[ ] Arthur, King of the Britons
[ ] Sir Lancelot the Brave
[x] Sir Robin the Not-Quite-So-Brave-as-Sir-Lancelot
[ ] Sir Bedevere the Wise
[ ] Sir Galahad the Pure
[ ] Møøse
Welcome, Sir Robin the Not-Quite-So-Brave-as-Sir-Lancelot
What is your age? 31
What is your quest?
Sir Robin the Not-Quite-So-Brave-as-Sir-Lancelot's quest (who is 31) is to seek the holy grail.

Installation

pip3 install cutie

Documentation

get_number

Get a number from user input. If an invalid number is entered the user will be prompted again.

Arguments

argument type default description
prompt str The prompt asking the user to input.
min_value float, optional - infinity The [inclusive] minimum value.
max_value float, optional infinity The [inclusive] maximum value.
allow_float bool, optional True Allow floats or force integers.

Returns

The number input by the user.

secure_input

Get secure input without showing it in the command line.

Arguments

argument type description
prompt str The prompt asking the user to input.

Returns

The secure input.

select

Select an option from a list.

Arguments

argument type default description
options List[str] The options to select from.
deselected_prefix str, optional [ ] Prefix for deselected option.
selected_prefix str, optional [x] Prefix for selected option.
selected_index int, optional 0 The index to be selected at first.

Returns

The index that has been selected.

prompt_yes_or_no

Prompt the user to input yes or no.

Arguments

argument type default description
question str The prompt asking the user to input.
yes_text str, optional Yes The text corresponding to 'yes'.
no_text str, optional No The text corresponding to 'no'.
has_to_match_case bool, optional False Does the case have to match.
enter_empty_confirms bool, optional True Does enter on empty string work.
default_is_yes bool, optional False Is yes selected by default
deselected_prefix str, optional Prefix if something is deselected.
selected_prefix str, optional > Prefix if something is selected
abort_value Optional[bool], optional None The value on interrupt.
char_prompt bool, optional True Add a [Y/N] to the prompt.

Returns

The bool what has been selected.

Contributing

If you want to contribute, please feel free to suggest features or implement some from the (roadmap)[#Roadmap], other ones that are still lacking, or bugfixes.

Also please encounter any issues and bugs you might find!

Authors

  • Currently this entire project is just by me.

License

The project is licensed under the MIT-License.

Acknowledgments

  • This project uses the module Readchar for direct input handling.

GNU Terry Pratchett

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

cutie-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

cutie-0.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file cutie-0.0.1.tar.gz.

File metadata

  • Download URL: cutie-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for cutie-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e2b84bf80d921ccfbf6819bba0318ff81a06e4e29fd4cb5398c98120e68d9f4d
MD5 e3ae3c66efdab5f2bfca930db1d3b710
BLAKE2b-256 a2bb733e500cf07d09594742b899924af0dcf74fb1f46ceaf3e354ac53e0346b

See more details on using hashes here.

File details

Details for the file cutie-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: cutie-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for cutie-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab40dde5326c2e424e429128649601f2379e54096c60601e8e58ba9521681831
MD5 53285114a1627dd3ce1892e2bcefa04a
BLAKE2b-256 eedd9fcff45caf94300bcbceffc4b276afe1ae91956b8bb50f882e55dedfd2dc

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