from typing import OrderedDict


def task_list_table_format(result):
    """Format task list as a table."""
    table_output = []
    for item in result:
        table_row = OrderedDict()
        table_row['Task Id'] = item['id']
        table_row['State'] = item['state']
        table_row['Exit Code'] = str(item['executionInfo']['exitCode']) \
            if item['executionInfo'] else ""
        table_row['Node Id'] = item['nodeInfo']['nodeId'] if item['nodeInfo'] else ""
        table_row['Command Line'] = item['commandLine']
        table_output.append(table_row)
    return table_output