Ejemplo n.º 1
0
def getargs(intp, arglist):
    args = CLIArgs()
    
    for i in arglist:
        if i[0] == "ARG":
            args.mandatory.append(i[1])
            args.long[i[1]] = "str"
            for short in shortarg(i[1]):
                if short not in args.short:
                    args.short[short] = i[1]
                    break
        elif i[0] == "DEFARG":
            args.long[i[1]] = typeof(intp.run(i[2]))
            for short in shortarg(i[1]):
                if short not in args.short:
                    args.short[short] = i[1]
                    break
        elif i[0] == "UNWRAPABLE":
            args.mandatory.append(i[1])
            if not args.dump:
                args.dump = i[1]
        elif i[0] == "UNWRAPABLEKW":
            if not args.kwdump:
                args.kwdump = i[1]
    
    return args
Ejemplo n.º 2
0
def run_main(intp, args):
    if "--help" in args or "-h" in args or "-?" in args \
            and "$$help" in intp.curr:
        __help = intp.curr["$$help"]
        if typeof(__help) == "str":
            print __help
        else:
            __help()
    elif "--version" in args and "$$version" in intp.curr:
        __version = intp.curr["$$version"]
        if typeof(__version) == "str":
            print __version
        else:
            __version()
    else:
        main = intp.curr["$$main"]
        schema = getargs(intp, main.arglist)
        kwargs = parseargs(args, schema)
        main(**kwargs)