__main__.py 925 B

1234567891011121314151617181920212223242526272829303132333435
  1. import sys
  2. def main(args=None):
  3. if args is None:
  4. args = sys.argv[1:]
  5. # TODO Handle library-wide options. Eg.:
  6. # --unicodedata
  7. # --verbose / other logging stuff
  8. # TODO Allow a way to run arbitrary modules? Useful for setting
  9. # library-wide options and calling another library. Eg.:
  10. #
  11. # $ fonttools --unicodedata=... fontmake ...
  12. #
  13. # This allows for a git-like command where thirdparty commands
  14. # can be added. Should we just try importing the fonttools
  15. # module first and try without if it fails?
  16. if len(sys.argv) < 2:
  17. sys.argv.append("help")
  18. if sys.argv[1] == "-h" or sys.argv[1] == "--help":
  19. sys.argv[1] = "help"
  20. mod = "fontTools." + sys.argv[1]
  21. sys.argv[1] = sys.argv[0] + " " + sys.argv[1]
  22. del sys.argv[0]
  23. import runpy
  24. runpy.run_module(mod, run_name="__main__")
  25. if __name__ == "__main__":
  26. sys.exit(main())