A bunch of useful click parameter types
Project description
click-params
A bunch of useful click parameter types.
Why?
I often find myself wanting to use a click parameter able to handle list of strings, so I decide to put this in a library and I ended adding more parameter types that can be useful for various scripts including network, mathematics and so on.
Installation
pip install click-params
click-params starts working from python 3.6. It has a few dependencies:
- click >= 7.0
- validators
Usage
import click
from click_params import Ipv4AddressListParamType
@click.command()
@click.option('-a', '--addresses', help='list of ipv4 addresses', prompt='list of ipv4 addresses to reserve',
type=Ipv4AddressListParamType())
def pool(addresses):
click.echo('reserved ips:')
for ip in addresses:
click.echo(ip)
$ pool --addresses='192.168.1.1,192.168.1.14'
reserved ips:
192.168.1.1
192.168.1.14
You can change the default separator "," by passing it when initializing the parameter type.
Documentation
Documentation is available at https://click-params.readthedocs.io/en/latest/.
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
click-params-0.2.0.tar.gz
(11.0 kB
view hashes)
Built Distribution
Close
Hashes for click_params-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dccd65c73987316be0d9df5200181688d079204bab1f1e116c804bdf4e1e2d7e |
|
MD5 | afc2ed155e1ac953278f254d0505072d |
|
BLAKE2b-256 | 31bc725117e77b678cf601bfdb2dc091acd78609bc861deadc2a350765f106ea |