def match_cmd(first, avail_cmds):
    targetcmd = [x for x in avail_cmds if x.__name__.startswith(first)]
    if (len(targetcmd) == 1):
        return targetcmd[0]
    elif (len(targetcmd) == 0):
        print(('unrecognized command: ' + first))
        return None
    else:
        print(('ambiguous command: ' + first))
        print(('matched commands: ' + ','.join((x.__name__ for x in targetcmd))))
        return None
def match_cmd(first, avail_cmds):
    targetcmd = [x for x in avail_cmds if x.__name__.startswith(first)]
    if (len(targetcmd) == 1):
        return targetcmd[0]
    elif (len(targetcmd) == 0):
        print(('unrecognized command: ' + first))
        return None
    else:
        print(('ambiguous command: ' + first))
        print(('matched commands: ' + ','.join((x.__name__ for x in targetcmd))))
        return None