项目作者: piccolo-orm

项目描述 :
Python CLI using type hints and docstrings.
高级语言: Python
项目地址: git://github.com/piccolo-orm/targ.git
创建时间: 2020-04-18T15:29:57Z
项目社区:https://github.com/piccolo-orm/targ

开源协议:MIT License

下载


Logo

targ

Build a Python CLI for your app, just using type hints and docstrings.

Just register your type annotated functions, and that’s it - there’s no special
syntax to learn, and it’s super easy.

  1. # main.py
  2. from targ import CLI
  3. def add(a: int, b: int):
  4. """
  5. Add the two numbers.
  6. :param a:
  7. The first number.
  8. :param b:
  9. The second number.
  10. """
  11. print(a + b)
  12. if __name__ == "__main__":
  13. cli = CLI()
  14. cli.register(add)
  15. cli.run()

And from the command line:

  1. >>> python main.py add 1 1
  2. 2

To get documentation:

  1. >>> python main.py add --help
  2. add
  3. ===
  4. Add the two numbers.
  5. Usage
  6. -----
  7. add a b
  8. Args
  9. ----
  10. a
  11. The first number.
  12. b
  13. The second number.

Documentation

The full documentation is available on Read the Docs.