假设我要创建一个看起来像这样的CLI
cliName user create
cliName user update
我该怎么做?
我试图做这样的事情-
@click.group()
def user():
print("USER")
pass
@user.command()
def create():
click.echo("create user called")
当我运行cliName user create
时,打印语句不会运行。一无所有。
答案 0 :(得分:2)
#!/usr/bin/env python
import click
@click.group()
def cli(**kwargs):
print(1)
@cli.group()
@click.option("--something")
@click.option("--else")
def what(**kwargs):
print(2)
@what.command()
@click.option("--chaa")
def ever(**kwargs):
print(3)
if __name__ == '__main__':
cli()
# ./cli.py what ever
# 1
# 2
# 3