from django.core.management.base import BaseCommand
from thezombies.tasks.main import crawl_agency_datasets


class Command(BaseCommand):
    """Start a task that crawl the datasets from an agency data catalog. This command will exit, but the task will run in the background"""
    args = '<agency_id ...>'

    def handle(self, *args, **options):
        if len(args) > 0:
            agency_id = args[0]
            if agency_id:
                task = crawl_agency_datasets.delay(agency_id)
                self.stdout.write(u'Running task with id {0}'.format(task.id))
                self.stdout.write(u'This can take many minutes...')
            else:
                self.stderr.write(u"Didn't get an agency_id!")

@@ -45,16 +45,53 @@
 Command%0A
+from thezombies.models import Agency%0A
 from the
@@ -752,8 +752,272 @@
 y_id!%22)%0A
+        else:%0A            self.stdout.write(u'Please provide an agency id:%5Cn')%0A            agency_list = u'%5Cn'.join(%5B'%7B0:2d%7D: %7B1%7D'.format(a.id, a.name) for a in Agency.objects.all()%5D)%0A            self.stdout.write(agency_list)%0A            self.stdout.write(u'%5Cn')%0A

Add message for when command is not supplied any arguments.