Welcome to click-types documentation!
click-types: Python library that provides useful click types
PyPI version
Codacy Badge
Documentation Status
click is the Command line interface creation kit
and it helps you to create command line interfaces with some few lines of code. Click comes with meaningful defauls to make starting with it as easy as possible.
A powerful feature of click is to develop custom types to convert and/or validate user input. There are several custom types in the wild but this repository is intended to collect such custom types to make it easily accessable.
Installation
Currently we support two ways of installing click-types
on your system. We will both illustrate short in the following sections.
Installing from pypi
We release all versions on pypi.org, so you can simply use pip
to install it.
pip install click-types
Install from repository
Alternatively you can install it from a local clone of our github repository.
$ git clone https://github.com/codeaffen/click-types.git
Cloning into 'click-types'...
remote: Enumerating objects: 83, done.
remote: Counting objects: 100% (83/83), done.
remote: Compressing objects: 100% (59/59), done.
remote: Total 83 (delta 25), reused 72 (delta 16), pack-reused 0
Unpacking objects: 100% (83/83), 29.77 KiB | 441.00 KiB/s, done.
$ cd click-types/
$ python setup.py install
Custom types
Name | Module | Description —- | —— | ———– AnsibleVaultParamType | click_types.ansible | Manages secret values in ansible vaults. This type open the configured vault put the value to the given path and close vault. SemVerParamType | click_types.coding | Provides validity checks for semantic versions. CIDRParamType | click_types.net | Checking a given IP network/prefix if it’s a valid CIDR. Both ip version (v4 and v6) are supported. VlanParamType | click_types.net | Validates vlan ids according to IEEE 802.1Q standard.
CHANGELOG
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning and Keep a Changelog.
Unreleased
New
Changes
Fixes
exit if key in path is not a dict
exit if vault can’t be decrypted
Breaks
1.0.1 - (2021-06-14)
New
added tests for existing types
Fixes
fix missing dependecies
click_types
click_types package
Python package that provides custom click types.
Submodules
click_types.ansible module
Module for custom click types regarding to ansible.
- class click_types.ansible.AnsibleVaultParamType(vault: str, secret: str, path: str)[source]
Bases:
click.types.ParamType
Provide a custom click type for ansible vaults.
- This custom click type provides managing passed values in a given vault.
decrypt vault
save passed value
encrypt vault
- convert(value, param, ctx)[source]
Open vault and save vaule at the given path.
- Parameters
value (str) – the value passed
param (str) – the parameter that we declared
ctx (str) – context of the command
- Returns
the passed value as a checked semver
- Return type
str
- name: str = 'vault'
the descriptive name of this type
- path
alias of
str
- secret
alias of
str
- vault
alias of
str
click_types.coding module
Module for custom click types regarding to development.
- class click_types.coding.SemVerParamType[source]
Bases:
click.types.ParamType
Provide a custom click type for semantic versions.
This custom click type provides validity checks for semantic versions.
- convert(value, param, ctx)[source]
Converts the value from string into semver type.
This method takes a string and check if this string belongs to semantic verstion definition. If the test is passed the value will be returned. If not a error message will be prompted.
- Parameters
value (str) – the value passed
param (str) – the parameter that we declared
ctx (str) – context of the command
- Returns
the passed value as a checked semver
- Return type
str
- name: str = 'semver'
the descriptive name of this type
click_types.net module
Module for custom click types regarding to network.
- class click_types.net.CIDRParamType[source]
Bases:
click.types.ParamType
Provide a custom click type for network cidr handling.
This custom click type provides validity check for network cidrs. Both ip version (v4 and v6) are supported.
- convert(value, param, ctx)[source]
Converts the value from string into cidr type.
This method takes a string and check if this string belongs to ipv4 or ipv6 cidr definition. If the test is passed the value will be returned. If not a error message will be prompted.
- Parameters
value (str) – the value passed
param (str) – the parameter that we declared
ctx (str) – context of the command
- Returns
the passed value as a checked cidr
- Return type
int
- name: str = 'cidr'
the descriptive name of this type
- class click_types.net.VlanIDParamType[source]
Bases:
click.types.ParamType
Provide a custom click type for vlan id handling.
This custom click type provides validity checks for vlan ids according to IEEE 802.1Q standard.
- convert(value, param, ctx)[source]
Converts the value from string into semver type.
This method tages a string and check if this string belongs to semantic verstion definition. If the test is passed the value will be returned. If not a error message will be prompted.
- Parameters
value (str) – the value passed
param (str) – the parameter that we declared
ctx (str) – context of the command
- Returns
the passed value as a checked vlan id
- Return type
int
- name: str = 'vlanid'
the descriptive name of this type
How to contribute to click-types
Did you found a bug
Make sure the bug is not already opened by another user.
If you can’t find an open issue which reflects your observed problem go ahead an open a new bug.
Provide as much information as mentioned in the bug report template.
Did you wrote a patch for an open bug
Open new pull request containing the patch.
Provide a clear description which describes the problem and the solution. Link the existing bug to the PR.
Do you want to add a new feature
Make sure there isn’t already a feature request.
If you can’t find an open feature request which describe your feature idea or parts of it feel free to open a new feature request.
Suggest your feature idea within the created feature request.
Provide as much discribtion as possible to enable others to have a good understanding of what you are doing.
Point out that you want to start to work on the new feature
Do you wnat to contribute to documentation
Write you documentation change.
Open a PR with your change.
Discuss with the team about your changes.
Thank you for any contribution
We will thank you for heed the contribution guidelines and we encourage you to contribute and join the team.