<div id="headline" align="center">
<h1>cmdtools</h1>
<p>A module for parsing and processing commands.</p>
<a href="https://github.com/HugeBrain16/cmdtools/actions/workflows/python-package.yml">
<img src="https://github.com/HugeBrain16/cmdtools/actions/workflows/python-package.yml/badge.svg" alt="tests"></img>
</a>
<a href="https://pypi.org/project/cmdtools-py">
<img src="https://img.shields.io/pypi/dw/cmdtools-py" alt="downloads"></img>
<img src="https://badge.fury.io/py/cmdtools-py.svg" alt="PyPI version"></img>
<img src="https://img.shields.io/pypi/pyversions/cmdtools-py" alt="Python version"></img>
</a>
<a href="https://codecov.io/gh/HugeBrain16/cmdtools">
<img src="https://codecov.io/gh/HugeBrain16/cmdtools/branch/main/graph/badge.svg?token=mynvRn223H"/>
</a>
</div>
## Installation
```
pip install --upgrade cmdtools-py
```
install latest commit from GitHub
```
pip install git+https://github.com/HugeBrain16/cmdtools.git
```
## Examples
more examples [here](https://github.com/HugeBrain16/cmdtools/tree/main/examples)
### Basic example
```py
import cmdtools
def ping():
print("pong.")
cmd = cmdtools.Cmd('/ping')
cmd.process_cmd(ping)
```
### Command with arguments
```py
import cmdtools
def give(name, item_name, item_amount):
print(f"You gave {item_amount} {item_name}s to {name}")
# surround argument that contains whitespaces with quotes
# set `convert_args` to `True` to automatically convert numbers argument
# this will raise an exception,
# if the number of arguments provided is less than the number of positional callback parameters.
cmd = cmdtools.Cmd('/give Josh "Golden Apple" 10', convert_args=True)
# check for command instance arguments data type.
# format indicates ['str','str','int'].
# integer or float can also match string format, and character 'c' if the argument only has 1 digit.
# `max_args` set to 3, check the first 3 arguments, the rest will get ignored,
# otherwise if it set to default,
# it will raise an exception if the number of arguments is not equal to the number of formats
if cmd.match_args('ssi', max_args=3):
cmd.process_cmd(give)
else:
print('Correct Usage: /give <name: [str]> <item-name: [str]> <item-amount: [int]>')
```
## Links
PyPI project: https://pypi.org/project/cmdtools-py
Source code: https://github.com/HugeBrain16/cmdtools
Issues tracker: https://github.com/HugeBrain16/cmdtools/issues
Documentation: ...
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共12个文件
py:4个
txt:3个
pkg-info:2个
资源分类:Python库 所属语言:Python 资源全名:cmdtools-py-2.4.8.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
cmdtools-py-2.4.8.tar.gz (12个子文件)
cmdtools-py-2.4.8
PKG-INFO 4KB
cmdtools
__init__.py 50B
ext
command.py 12KB
cmdtools.py 13KB
LICENSE 1KB
setup.cfg 42B
setup.py 1KB
cmdtools_py.egg-info
PKG-INFO 4KB
SOURCES.txt 256B
top_level.txt 22B
dependency_links.txt 1B
README.md 2KB
共 12 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 数据库课程设计on-model-for-netwo开发笔记
- linux常用命令大全mage-processing-m开发笔记
- mysql安装配置教程droid-m开发笔记
- PWMmodel-for-network-ids-ma开发笔记
- apache-doris-build-env-for-2.0.c
- apache-doris-build-env-for-2.0.b
- apache-doris-build-env-for-2.0.a
- 1719422999141832_lls-release_cqfw.mobileconfig
- 数据库课程设计processing-m开发笔记
- pycharm安装教程ention-model-for-开发笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功