]> code.delx.au - offlineimap/commitdiff
Add option '-k' for overriding config options
authorRiccardo Murri <riccardo.murri@gmail.com>
Thu, 3 Jan 2008 03:13:04 +0000 (04:13 +0100)
committerRiccardo Murri <riccardo.murri@gmail.com>
Thu, 3 Jan 2008 03:13:04 +0000 (04:13 +0100)
offlineimap.sgml
offlineimap/init.py
offlineimap/version.py

index 5b5d148827c28ad1a340a77aac75f887e442df4e..1fc5bd61f21e5abb482478ccf937bb09dda763b0 100644 (file)
@@ -373,6 +373,17 @@ cd offlineimap-x.y.z</ProgramListing>
              will debug the threading model.
            </para></listitem>
          </varlistentry>
+        <varlistentry><term>-k [<replaceable>section</replaceable>:]<replaceable>option</replaceable>=<replaceable>value</replaceable>
+          </term>
+          <listitem><para> Override configuration file option.  If
+              "section" is omitted, it defaults
+              to <property>general</property>.  Any underscores "_" in
+              the section name are replaced with spaces: for instance,
+              to override option <property>autorefresh</property> in
+              the "[Account Personal]" section in the config file one
+              would use "-k Account_Personal:autorefresh=30".
+          </para></listitem>
+        </varlistentry>
          <varlistentry><term>-l
          <replaceable>filename</replaceable></term>
            <listitem><para>
index 9824f055036b629f75d21ed85334c54dfc628ca1..d901864929f6c30e61f9f947c1ca2142bc7a1b55 100644 (file)
@@ -53,7 +53,7 @@ def startup(versionno):
         sys.stdout.write(version.getcmdhelp() + "\n")
         sys.exit(0)
 
-    for optlist in getopt(sys.argv[1:], 'P:1oqa:c:d:l:u:h')[0]:
+    for optlist in getopt(sys.argv[1:], 'P:1oqa:c:d:l:u:hk:')[0]:
         options[optlist[0]] = optlist[1]
 
     if options.has_key('-h'):
@@ -79,6 +79,17 @@ def startup(versionno):
 
     config.read(configfilename)
 
+    # override config values with option '-k'
+    for option in options.keys():
+        if option == '-k':
+            (key, value) = options['-k'].split('=', 1)
+            if ':' in key:
+                (secname, key) = key.split(':', 1)
+                section = secname.replace("_", " ")
+            else:
+                section = "general"
+            config.set(section, key, value)
+
     ui = offlineimap.ui.detector.findUI(config, options.get('-u'))
     UIBase.setglobalui(ui)
 
index 93d1ca3a82a65fc01d3deea35a40d481e8b604e2..0a46dec015f326e7a82a0d5cfc040dc674d6e02c 100644 (file)
@@ -94,7 +94,15 @@ def getcmdhelp():
               one else.  The maildir option will enable debugging
               for certain Maildir operations.
 
-       -o     Run  only once, ignoring any autorefresh setting in
+       -k [section:]option=value
+              Override configuration file option.  If"section" is
+              omitted, it defaults to "general".  Any underscores
+              "_" in the section name are replaced with spaces:
+              for instance,  to override  option "autorefresh" in
+              the "[Account Personal]" section in the config file
+              one would use "-k Account_Personal:autorefresh=30".
+              
+       -o     Run only once,  ignoring any autorefresh setting in
               the config file.
 
        -q     Run  only quick synchronizations.   Ignore any flag