Skip to main content

Interact cli

PyPI https://img.shields.io/pypi/pyversions/interact-cli.svg?branch=master&color=blue https://img.shields.io/pypi/dm/interact-cli.svg?branch=master&color=blue https://api.travis-ci.com/caizhengxin/interact-cli.svg?branch=master&color=blue Documentation Status https://img.shields.io/github/languages/code-size/caizhengxin/interact-cli.svg?branch=master https://img.shields.io/pypi/l/interact-cli.svg

Interactive command line tool.

Features

  • Interact input

  • Supports multiple data types

  • Support input check

  • Support regex, see network.json

Support type

  • boolean

  • string

  • int

  • float

  • list

  • choice

  • mac

  • ipv4

  • cidr, eg: 192.168.1.1/24

  • hex

Installation

To install interact-cli, run this command in your terminal:

$ pip3 install interact-cli

or:

$ git clone https://github.com/caizhengxin/interact-cli.git
$ cd interact-cli
$ pip3 install -e .

Usage

See interact.json

string:

from interact import interacts


config = {
    "name": {
        "type": "string",
        "default": "jankinca",
        "max_length": 10,
        "min_length": 1,
        "description": "Your name"
    }
}


if __name__ == "__main__":
    """
    Your name [jankinca]: sssssssssssss
    Error: Invalided `sssssssssssss`
    Your name [jankinca]: jankincai
    """

    print(interacts(config).name)

regex:

from interact import interacts


config = {
    "ipv4": {
        "type": "string",
        "regex": r"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$",
        "default": "192.168.166.12",
        "description": "IPv4 address"
    }
}


if __name__ == "__main__":
    """
    IPv4 address [192.168.166.12]: 22
    Error: Invalided `22`
    IPv4 address [192.168.166.12]: 192.168.166.2
    """

    print(interacts(config).ipv4)

when:

from interact import interacts


config = {
    "use_code_hosting": {
        "type": "boolean",
        "default": True,
        "description": "Use code hosting platform"
    },
    "code_hosting": {
        "type": "choice",
        "default": 1,
        "choice": [
            "github",
            "gitee",
            "gitlab"
        ],
        "description": "Code hosting",
        "when": "use_code_hosting == true"
    },
    "code_hosting_username": {
        "type": "string",
        "default": "jankincai",
        "description": "Your code hosting username",
        "when": "use_code_hosting == true"
    }
}


if __name__ == "__main__":
    """
    Use code hosting platform [y]: y
    Select code hosting:
    1 - github
    2 - gitee
    3 - gitlab
    Choose from [1]:
    Your code hosting username [jankincai]: jankincai

    {'use_code_hosting': True, 'code_hosting': 'github', 'code_hosting_username': 'jankincai'}
    """

    """
    Use code hosting platform [y]: n
    {'use_code_hosting': False, 'code_hosting': None, 'code_hosting_username': None}
    """

    print(interacts(config).get_interact_data())

See demo

Credits

This package was created with Cookiecutter and the caizhengxin/cookiecutter-package project template.

Metadata

Release files for interact-cli 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for interact-cli 0.5.0
File Size Uploaded Provenance Actions
interact-cli-0.5.0.tar.gz 9.3 kB Without provenance Details for interact-cli-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for interact-cli 0.5.0
File Interpreter ABI Platform Actions
interact_cli-0.5.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for interact_cli-0.5.0-py2.py3-none-any.whl

Total release size: 19.1 kB

Release files / interact-cli-0.5.0.tar.gz

Download URL interact-cli-0.5.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
76a1cbe2193835761fd6f4133399411fad2ea796aeed6edc652a0a2623c40d9c
BLAKE2b-256 checksum
How to use checksums
d003aacfd3e05440c3ec3788694b3a2db233e6b30f44cf23941902552ae370de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9

Release files / interact_cli-0.5.0-py2.py3-none-any.whl

Download URL interact_cli-0.5.0-py2.py3-none-any.whl
Size 9.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
21378ac64523fbaece222716ea450d1d9e1aeaadf7d60264c316f684affb9ab1
BLAKE2b-256 checksum
How to use checksums
880324b9601f6844a9c3941e086605136c5b2907cbe5b9e99aa25e8df257b101
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9

Security for interact-cli 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page