def selectCommands(commands, indexList, lineNumbers=False):
    """Prints commands indexed by the list passed."""

    commandList = []

    for index in indexList:
        record = commands[index]['cmd']

        if lineNumbers:
            record = (index, record)

        commandList.append(record)

    return commandList