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