Skip to main content

Simple python package to handle cli user input.

Project description

Pypi project Pypi total project downloads

Simple python package to handle CLI user input.

How do I install this package?

As usual, just download it using pip:

pip install userinput

Available validators

Some commonly used validators are available with the package.

Validator name Description
email Check if given input string is a valid email.
version_code Check if given input string is a valid version code.
url Check if given input string is a valid URL. Does not check if given URL is online.
human_bool Check if given input string is a human Boolean, such as “yes”, “y”, “true”, “si”, “no”, “n”, “false”.
integer Check if given input string is a integer numeric value.
positive_integer Check if given input string is a positive integer numeric value.
non_empty Check if given input string is not empty.
hostname Check if given input string is a reachable host name.
ip Check if given input string is a reachable IP address.

Use them as follows:

from userinput import userinput

result = userinput(
    "my_label",
    validator="validator name goes here"
)

You can also chain validators. They will be called in the order you provide.

from userinput import userinput

result = userinput(
    "my_label",
    validator=[
        "validator name goes here",
        my_custom_validation_function
    ]
)

Available sanitizers

Some commonly used sanitizers are available with the package.

Validator name Description
human_bool Cast human Boolean specified above in validators to python Booleans.
strip Remove padding spaces and repeated spaces.

Use them as follows:

from userinput import userinput

result = userinput(
    "my_label",
    sanitizer="sanitizer name goes here"
)

You can also chain sanitizers. They will be called in the order you provide.

from userinput import userinput

result = userinput(
    "my_label",
    sanitizer=[
        "sanitizer name goes here",
        my_custom_sanitification_function
    ]
)

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

userinput-1.0.17.tar.gz (7.2 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page