Newer
Older
tac2grc / src / arguments.py
@lukas lukas on 14 Aug 2022 716 bytes initial commit
import getopt

def exitUsage():
    print("usage: %s <.tasrc file> -i <C files directory> -o <output file>" % sys.argv[0])
    sys.exit(1)

def readArguments(args):
    sourceDirectories = []
    outputFile = ""
    try:
        options, _ = getopt.getopt(args, "hi:o:")
    except getopt.GetoptError:
        exitUsage()
    for option, arg in options:
        if option == "-h":
            exitUsage()
        elif option == "-o":
            outputFile = arg
        elif option == "-i":
            sourceDirectories.append(arg)
    if outputFile == "":
        exitUsage()
    if len(sourceDirectories) == 0:
        print("WARNING: no source directories specified!")
    return outputFile, sourceDirectories