Skip to content

Latest commit

History

History
55 lines (37 loc) · 1.18 KB

File metadata and controls

55 lines (37 loc) · 1.18 KB

clicktypes

Additional types for the click module that I find useful.

For a list of available types check the README file from the module.

Installation

Install from PyPI:

## Python 3python3-mpipinstallclicktypes## PyPy3pypy3-mpipinstallclicktypes

Examples

The following are some examples. For complete examples check the appropriate README.

Networking

If you accept an IP address parameter:

fromclicktypes.networkimportIPAddressParam@click.argument('ip',nargs=-1,required=True,type=IPAddressParam(),)

This will validate the IP or IP's provided are IPv4 or IPv6 addresses and return them as an IPv4Address or IPv6Address object.

Web

If you accept an email address parameter:

fromclicktypes.webimportEmailParam@click.argument('email',nargs=-1,required=True,type=EmailParam(),)

This will validate the email address provided matches an approved regex and it will convert it to lowercase.