【发布时间】:2020-09-17 06:20:48
【问题描述】:
我是 python 的新成员,目前在 Click 模块上工作。所以在这里我怀疑只为主要的 cli 功能提供输入。但我想为我的所有功能一一提供输入。可以点击吗?感谢您的提前。
@click.option('--create', default='sub', help='Create')
@click.command()
def create(create):
click.echo('create called')
os.system('curl http://127.0.0.1:5000/create')
@click.option('--conn', default='in', help='connect to server')
@click.command()
def conn(conn):
click.echo('conn called')
os.system('curl http://127.0.0.1:5000/')
还有我的 setup.py
from setuptools import setup
setup(
name="hello",
version='0.1',
py_modules=['hello'],
install_requires=[
'Click',
],
entry_points='''
[console_scripts]
hello=hello:cli
''',
)
我的输出期望
$ hello --conn in
success
hello --create sub
success
【问题讨论】:
标签: python python-3.x command-line-interface argparse python-click