#!/usr/bin/python

import argparse
from fjd import Dispatcher


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Start a worker process.')
    parser.add_argument('--interval', type=float, default=.1,
                        help="The interval (in seconds) between polling for jobs and workers.")
    parser.add_argument('--end_when_jobs_are_done', action='store_true',
                    help="If True, the dispatcher stops if no jobs are queued.")
    parser.add_argument('--end_callback', type=str, help="if end_when_jobs_are_done"\
                         " is True, call this command when jobs are done,"\
                         " before quitting.")
    parser.add_argument('--status_only', action='store_true',
                    help="Only display state of jobs and then quit.")

    parser.add_argument('--project', type=str, help="Custom identifier (useful"\
                                  " when fjd is used to run several projects).")
    args = parser.parse_args()
    Dispatcher(project=args.project, interval=args.interval,
               end_when_jobs_are_done=args.end_when_jobs_are_done,
               status_only=args.status_only)

