cmdline.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on 2020/5/8 2:24 PM
  4. ---------
  5. @summary:
  6. ---------
  7. @author: Boris
  8. @email: boris_liu@foxmail.com
  9. """
  10. import sys
  11. from os.path import dirname, join
  12. from feapder.commands import create_builder
  13. from feapder.commands import shell
  14. def _print_commands():
  15. with open(join(dirname(dirname(__file__)), "VERSION"), "rb") as f:
  16. version = f.read().decode("ascii").strip()
  17. print("feapder {}".format(version))
  18. print("\nUsage:")
  19. print(" feapder <command> [options] [args]\n")
  20. print("Available commands:")
  21. cmds = {"create": "create project、spider、item and so on", "shell": "debug response"}
  22. for cmdname, cmdclass in sorted(cmds.items()):
  23. print(" %-13s %s" % (cmdname, cmdclass))
  24. print('\nUse "feapder <command> -h" to see more info about a command')
  25. def execute():
  26. args = sys.argv
  27. if len(args) < 2:
  28. _print_commands()
  29. return
  30. command = args.pop(1)
  31. if command == "create":
  32. create_builder.main()
  33. elif command == "shell":
  34. shell.main()
  35. else:
  36. _print_commands()