djangoのコマンドでオプション引数の指定の仕方とか
下記の通りに行うそうで。
# coding: utf-8 import os import sys import logging from django.core.management.base import BaseCommand from optparse import make_option class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--filepath',dest='filepath'), ) def handle(self, *args, **options): self.check_filepath_option(options) def check_filepath_option(self, options): try: fpath = options['filepath'] except KeyError: print 'no --filepath option' sys.exit(1) if not os.path.exists(fpath): print 'invalid filepath' sys.exit(1)