#!/usr/bin/python3
'''
Created on 02.08.2019

@author: mdoc
'''

import sys
from mdoc import worker

usage = 'mdoc <source> <target-format>'

def command_dispatch(args):
    
    # check runtime parameters
    if len(args) < 2:
        raise RuntimeError("mdoc needs 2 arguments.")
    
    file = args[0]
    format = args[1]
    
    return worker.convert(file, format)
    

# evaulate runtime parameters
if __name__ == '__main__':
    try:
        ret = command_dispatch(sys.argv[1:])
        if ret != 0:
            print (usage) 
        exit (ret)
    except Exception as e:
        print (e)
        print (usage)
        raise