.. versionadded:: 2015.8.0

    List all detectable jobs and associated functions

    CLI Example:

    .. code-block:: bash

        salt-run jobs.last_run
        salt-run jobs.last_run target=nodename
        salt-run jobs.last_run function='cmd.run'
        salt-run jobs.last_run metadata="{'foo': 'bar'}"

def last_run(ext_source=None,
             outputter=None,
             metadata=None,
             function=None,
             target=None,
             display_progress=False):
    '''
    .. versionadded:: 2015.8.0

    List all detectable jobs and associated functions

    CLI Example:

    .. code-block:: bash

        salt-run jobs.last_run
        salt-run jobs.last_run target=nodename
        salt-run jobs.last_run function='cmd.run'
        salt-run jobs.last_run metadata="{'foo': 'bar'}"
    '''

    if metadata:
        if not isinstance(metadata, dict):
            log.info('The metadata parameter must be specified as a dictionary')
            return False

    _all_jobs = list_jobs(ext_source=ext_source,
                          outputter=outputter,
                          search_metadata=metadata,
                          search_function=function,
                          search_target=target,
                          display_progress=display_progress)
    if _all_jobs:
        last_job = sorted(_all_jobs)[-1]
        return print_job(last_job, ext_source)
    else:
        return False