diff --git a/scrapy/trunk/docs/topics/settings.rst b/scrapy/trunk/docs/topics/settings.rst index ac4a86df0..142b32dbc 100644 --- a/scrapy/trunk/docs/topics/settings.rst +++ b/scrapy/trunk/docs/topics/settings.rst @@ -41,11 +41,18 @@ Example:: >>> from scrapy.conf import settings >>> settings.overrides['LOG_ENABLED'] = True -2. Environment variables ------------------------- +You can also override one (or more) settings from command line using the +``--set`` command line argument. .. highlight:: sh +Example:: + + scrapy-ctl.py crawl domain.com --set=LOG_FILE:/tmp/scrapy.log + +2. Environment variables +------------------------ + You can populate settings using environment variables prefixed with ``SCRAPY_``. For example, to change the log file location:: diff --git a/scrapy/trunk/scrapy/command/models.py b/scrapy/trunk/scrapy/command/models.py index 0c10b8b42..539f0f154 100644 --- a/scrapy/trunk/scrapy/command/models.py +++ b/scrapy/trunk/scrapy/command/models.py @@ -46,7 +46,7 @@ class ScrapyCommand(object): parser.add_option("--profile", dest="profile", default=None, help="write profiling stats in FILE, to analyze later with: python -m pstats FILE", metavar="FILE") parser.add_option("--pidfile", dest="pidfile", help="Write process pid to file FILE", metavar="FILE") parser.add_option("--set", dest="settings", action="append", metavar="SETTING:VALUE", default=[], - help="Override Scrapy setting SETTING with VALUE") + help="Override Scrapy setting SETTING with VALUE. May be repeated.") def process_options(self, args, opts): if opts.logfile: @@ -74,10 +74,10 @@ class ScrapyCommand(object): for setting in opts.settings: if ':' in setting: - name, val = setting.split(':') + name, val = setting.split(':', 1) settings.overrides[name] = val else: - sys.stderr.write("%s: invalid argument --set=%s - proper format is -set=SETTING:VALUE'\n" % (sys.argv[0], setting)) + sys.stderr.write("%s: invalid argument --set=%s - proper format is --set=SETTING:VALUE'\n" % (sys.argv[0], setting)) sys.exit(2) def run(self, args, opts):