MaterialXglTF 1.39.0.1
Loading...
Searching...
No Matches
__main__.py
1import sys, os
2import subprocess
3
4def main() -> int:
5 '''
6 Main entry point for running commands in the package.
7 '''
8 argCount = len(sys.argv)
9 if argCount < 2:
10 print('No arguments provided. Use -h or --help for help.')
11 return 1
12 if sys.argv[1] == '-h' or sys.argv[1] == '--help':
13 print('Usage: python -m materialxgltf <command> [options] where command is mtlx2gltf or gltf2mtlx')
14
15 # Check if the command is valid
16 cmdArgs = sys.argv[1:]
17 if cmdArgs[0] == 'mtlx2gltf':
18 cmdArgs[0] = 'mtlx2gltf.py'
19 elif cmdArgs[0] == 'gltf2mtlx':
20 cmdArgs[0] = 'gltf2mtlx.py'
21 else:
22 print('Unknown command specified:', cmdArgs[0])
23 return 1
24
25 # Build the command
26 cmd = ' '.join(cmdArgs)
27 packageLocation = os.path.dirname(__file__)
28 cmd = 'python ' + packageLocation + '/' + cmd
29
30 # Run the command
31 return subprocess.call(cmd, shell=True)
32
33if __name__ == '__main__':
34 sys.exit(main())