pip install pycli python from pycli import Command python from pycli import Command @Command() def hello(): print("Hello, world!") python from pycli import Command, arg @Command() @arg("name", help="The name of the user") def hello(name): print("Hello,", name) python from pycli import Command, arg @Command() @arg("name", help="The name of the user") def hello(self): if self.args.name: print("Hello,", self.args.name) else: print("Hello, world!") python from pycli import Command, arg, subcommand @Command() def calculator(self): pass @subcommand() @arg("a", type=int, help="The first number") @arg("b", type=int, help="The second number") def add(self): result = self.args.a + self.args.b print("Result:", result) @subcommand() @arg("a", type=int, help="The first number") @arg("b", type=int, help="The second number") def subtract(self): result = self.args.a - self.args.b print("Result:", result) python from pycli import Command, arg, subcommand @Command() def calculator(self): pass @subcommand() @arg("a", type=int, help="The first number") @arg("b", type=int, help="The second number") def add(self): result = self.args.a + self.args.b print("Result:", result) @subcommand() @arg("a", type=int, help="The first number") @arg("b", type=int, help="The second number") def subtract(self): result = self.args.a - self.args.b print("Result:", result)


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