项目作者: click-contrib

项目描述 :
Bunch of click parameters to use
高级语言: Python
项目地址: git://github.com/click-contrib/click_params.git
创建时间: 2019-06-17T14:13:21Z
项目社区:https://github.com/click-contrib/click_params

开源协议:Apache License 2.0

下载


click-params

Pypi version

Coverage Status
Documentation Status
License Apache 2
Ruff
Poetry

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

  1. pip install click-params

click-params starts working from python 3.8. It has a few dependencies:

Usage

  1. import click
  2. from click_params import Ipv4AddressListParamType
  3. @click.command()
  4. @click.option('-a', '--addresses', help='list of ipv4 addresses', prompt='list of ipv4 addresses to reserve',
  5. type=Ipv4AddressListParamType())
  6. def pool(addresses):
  7. click.echo('reserved ips:')
  8. for ip in addresses:
  9. click.echo(ip)
  1. $ pool --addresses='192.168.1.1,192.168.1.14'
  2. reserved ips:
  3. 192.168.1.1
  4. 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/.