]> wagnertech.de Git - mDoc.git/blob - python/mDoc/mdoc.py
pydev-ts
[mDoc.git] / python / mDoc / mdoc.py
1 #!/usr/bin/python3
2 '''
3 Created on 02.08.2019
4
5 @author: mdoc
6 '''
7
8 import sys
9 from mdoc import worker
10
11 usage = 'mdoc <source> <target-format>'
12
13 def command_dispatch(args):
14     
15     # check runtime parameters
16     if len(args) < 2:
17         raise RuntimeError("mdoc needs 2 arguments.")
18     
19     file = args[0]
20     format = args[1]
21     
22     return worker.convert(file, format)
23     
24
25 # evaulate runtime parameters
26 if __name__ == '__main__':
27     try:
28         ret = command_dispatch(sys.argv[1:])
29         if ret != 0:
30             print (usage) 
31         exit (ret)
32     except Exception as e:
33         print (e)
34         print (usage)
35         raise