python import pycli cli = pycli.Command("mycli", "A simple CLI tool") hello_cmd = cli.command("hello", "Greet the user") hello_cmd.add_argument("name", help="Name of the user") hello_cmd.add_option("-g", "--greeting", help="Custom greeting") @hello_cmd.handler def handle_hello(args): greeting = args.greeting or "Hello" print(f"{greeting}, {args.name}!") cli.add_help_command() cli.run() $ mycli hello --name John --greeting "Hey" Hey, John!


上一篇:
下一篇:
切换中文