try this:
create a file under yourapp/management/commands/yourcommand.py
with the following content:
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'A description of your command'
def add_arguments(self, parser):
parser.add_argument(
'--url', dest='url', required=True,
help='the url to process',
)
def handle(self, *args, **options):
url = options['url']
# process the url
then you can call your command with
python manage.py yourcommand --url http://example.com
and either:
python manage.py --help
or
python manage.py yourcommand --help
will show the description of your command and the argument.
if you don't want to name the argument (the --url
part), like in your example, just read the url('s) form args
:
def handle(self, *args, **kwargs):
for url in args:
# process the url
hope this helps.