<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/larch/config.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -6,9 +6,16 @@ Version 1.1.0 (git)
     database, which allows Larch to resync and resume interrupted syncs much
     more quickly without having to rescan all messages. As a result, SQLite 3 is
     now a dependency.
+  * Larch now loads config options from ~/.larch/config.yaml if it exists, or
+    from the file specified by the --config command-line option. This file may
+    contain multiple sections. If a section name is specified via the
+    command-line, Larch will use the options in that section for the session;
+    otherwise it will use the options in the &quot;default&quot; section. See the README
+    for more details.
   * Folders are now copied recursively by default.
   * Progress information is now displayed regularly while scanning large
     mailboxes.
+  * Added short versions of common command-line options.
   * The --fast-scan option has been removed.
 
 Version 1.0.2 (2009-08-05)</diff>
      <filename>HISTORY</filename>
    </modified>
    <modified>
      <diff>@@ -2,90 +2,99 @@
 
 Larch is a tool to copy messages from one IMAP server to another quickly and
 safely. It's smart enough not to copy messages that already exist on the
-destination and robust enough to deal with ornery or misbehaving servers.
+destination and robust enough to deal with interruptions caused by flaky
+connections or misbehaving servers.
 
 Larch is particularly well-suited for copying email to, from, or between Gmail
 accounts.
 
 *Author*::    Ryan Grove (mailto:ryan@wonko.com)
-*Version*::   1.0.2 (2009-08-05)
+*Version*::   1.1.0 (git)
 *Copyright*:: Copyright (c) 2009 Ryan Grove. All rights reserved.
 *License*::   GPL 2.0 (http://opensource.org/licenses/gpl-2.0.php)
 *Website*::   http://github.com/rgrove/larch
 
 == Installation
 
-Install Larch via RubyGems:
+Install the latest stable version of Larch via RubyGems:
 
   gem install larch
 
-== Usage
-
-  larch --from &lt;uri&gt; --to &lt;uri&gt; [options]
+Or you can install the latest development version from GitHub:
 
-  Required:
-       --from, -f &lt;s&gt;:   URI of the source IMAP server.
-         --to, -t &lt;s&gt;:   URI of the destination IMAP server.
-
-  Copy Options:
-                --all:   Copy all folders recursively
-     --all-subscribed:   Copy all subscribed folders recursively
-       --exclude &lt;s+&gt;:   List of mailbox names/patterns that shouldn't be
-                         copied
-   --exclude-file &lt;s&gt;:   Filename containing mailbox names/patterns that
-                         shouldn't be copied
-    --from-folder &lt;s&gt;:   Source folder to copy from (default: INBOX)
-      --from-pass &lt;s&gt;:   Source server password (default: prompt)
-      --from-user &lt;s&gt;:   Source server username (default: prompt)
-      --to-folder &lt;s&gt;:   Destination folder to copy to (default: INBOX)
-        --to-pass &lt;s&gt;:   Destination server password (default: prompt)
-        --to-user &lt;s&gt;:   Destination server username (default: prompt)
+  gem sources -a http://gems.github.com
+  gem install rgrove-larch
 
-  General Options:
-        --dry-run, -n:   Don't actually make any changes.
-          --fast-scan:   Use a faster (but less accurate) method to scan
-                         mailboxes. This may result in messages being
-                         re-copied.
-    --max-retries &lt;i&gt;:   Maximum number of times to retry after a recoverable
-                         error (default: 3)
-   --no-create-folder:   Don't create destination folders that don't already
-                         exist
-      --ssl-certs &lt;s&gt;:   Path to a trusted certificate bundle to use to
-                         verify server SSL certificates
-         --ssl-verify:   Verify server SSL certificates
-  --verbosity, -V &lt;s&gt;:   Output verbosity: debug, info, warn, error, or fatal
-                         (default: info)
-        --version, -v:   Print version and exit
-           --help, -h:   Show this message
-
-== Examples
-
-Larch is run from the command line. At a minimum, you must specify a source
-server and a destination server in the form of IMAP URIs. You may also specify
-one or more options:
+== Usage
 
+  larch [config section] [options]
   larch --from &lt;uri&gt; --to &lt;uri&gt; [options]
 
-For an overview of all available command-line options, run:
-
-  larch --help
+  Server Options:
+         --from, -f &lt;s&gt;:   URI of the source IMAP server.
+  --from-folder, -F &lt;s&gt;:   Source folder to copy from (default: INBOX)
+    --from-pass, -p &lt;s&gt;:   Source server password (default: prompt)
+    --from-user, -u &lt;s&gt;:   Source server username (default: prompt)
+           --to, -t &lt;s&gt;:   URI of the destination IMAP server.
+    --to-folder, -T &lt;s&gt;:   Destination folder to copy to (default: INBOX)
+      --to-pass, -P &lt;s&gt;:   Destination server password (default: prompt)
+      --to-user, -U &lt;s&gt;:   Destination server username (default: prompt)
+
+  Sync Options:
+              --all, -a:   Copy all folders recursively
+   --all-subscribed, -s:   Copy all subscribed folders recursively
+         --exclude &lt;s+&gt;:   List of mailbox names/patterns that shouldn't be
+                           copied
+     --exclude-file &lt;s&gt;:   Filename containing mailbox names/patterns that
+                           shouldn't be copied
 
-Specify a source server and a destination server and Larch will prompt you for
-the necessary usernames and passwords, then sync the contents of the source's
-+INBOX+ folder to the destination:
+  General Options:
+       --config, -c &lt;s&gt;:   Specify a non-default config file to use (default:
+                           ~/.larch/config.yaml)
+         --database &lt;s&gt;:   Specify a non-default message database to use
+                           (default: ~/.larch/larch.db)
+          --dry-run, -n:   Don't actually make any changes
+      --max-retries &lt;i&gt;:   Maximum number of times to retry after a recoverable
+                           error (default: 3)
+     --no-create-folder:   Don't create destination folders that don't already
+                           exist
+        --ssl-certs &lt;s&gt;:   Path to a trusted certificate bundle to use to
+                           verify server SSL certificates
+           --ssl-verify:   Verify server SSL certificates
+    --verbosity, -V &lt;s&gt;:   Output verbosity: debug, info, warn, error, or fatal
+                           (default: info)
+          --version, -v:   Print version and exit
+             --help, -h:   Show this message
+
+== Usage Examples
+
+Larch is run from the command line. The following examples demonstrate how to
+run Larch using only command line arguments, but you may also place these
+options in a config file and run Larch without any arguments if you prefer. See
+the &quot;Configuration&quot; section below for more details.
+
+For an overview of all available options, run:
+
+  larch -h
+
+At a minimum, you must &lt;b&gt;specify a source server and a destination server&lt;/b&gt;
+in the form of IMAP URIs:
 
   larch --from imap://mail.example.com --to imap://imap.gmail.com
 
+Larch will prompt you for the necessary usernames and passwords, then sync the
+contents of the source's +INBOX+ folder to the destination's INBOX folder.
+
 To &lt;b&gt;connect using SSL&lt;/b&gt;, specify a URI beginning with &lt;tt&gt;imaps://&lt;/tt&gt;:
 
   larch --from imaps://mail.example.com --to imaps://imap.gmail.com
 
 If you'd like to &lt;b&gt;sync a specific folder&lt;/b&gt; other than +INBOX+, specify the
 source and destination folders using &lt;tt&gt;--from-folder&lt;/tt&gt; and
-&lt;tt&gt;--to-folder&lt;/tt&gt;:
+&lt;tt&gt;--to-folder&lt;/tt&gt;. Folder names containing spaces must be enclosed in quotes:
 
   larch --from imaps://mail.example.com --to imaps://imap.gmail.com \
-    --from-folder &quot;Sent Mail&quot; --to-folder &quot;Sent Mail&quot;
+    --from-folder 'Sent Mail' --to-folder 'Sent Mail'
 
 To &lt;b&gt;sync all folders&lt;/b&gt;, use the &lt;tt&gt;--all&lt;/tt&gt; option (or
 &lt;tt&gt;--all-subscribed&lt;/tt&gt; if you only want to &lt;b&gt;sync subscribed folders&lt;/b&gt;):
@@ -99,7 +108,7 @@ already exist. To prevent this, add the &lt;tt&gt;--no-create-folder&lt;/tt&gt; option:
     --no-create-folder
 
 You can &lt;b&gt;prevent Larch from syncing one or more folders&lt;/b&gt; by using the
-&lt;tt&gt;--exclude&lt;/tt&gt; option:
+&lt;tt&gt;--exclude&lt;/tt&gt; option, which accepts multiple arguments:
 
   larch --from imaps://mail.example.com --to imaps://imap.gmail.com --all \
     --exclude Spam Trash Drafts &quot;[Gmail]/*&quot;
@@ -112,10 +121,83 @@ option:
     --exclude-file exclude.txt
 
 The wildcard characters &lt;tt&gt;*&lt;/tt&gt; and &lt;tt&gt;?&lt;/tt&gt; are supported in exclusion
-lists. You can also use a regular expression by enclosing a pattern in
+lists. You may also use a regular expression by enclosing a pattern in
 forward slashes, so the previous example could be achieved with the
 pattern &lt;tt&gt;/(Spam|Trash|Drafts|\[Gmail\]\/.*)/&lt;/tt&gt;
 
+== Configuration
+
+While it's possible to control Larch entirely from the command line, this can be
+inconvenient if you need to specify a lot of options or if you run Larch
+frequently and can't always remember which options to use. Using a configuration
+file can simplify things.
+
+By default, Larch looks for a config file at &lt;tt&gt;~/.larch/config.yaml&lt;/tt&gt; and
+uses it if found. You may specify a custom config file using the
+&lt;tt&gt;--config&lt;/tt&gt; command line option.
+
+The Larch configuration file is a simple YAML[http://yaml.org/] file that may
+contain multiple sections, each with a different set of options, as well as a
+special +default+ section. The options in the +default+ section will be used
+unless they're overridden either in another config section or on the command
+line.
+
+=== Example
+
+Here's a sample Larch config file:
+
+  default:
+    all-subscribed: true # Copy all subscribed folders by default
+
+  # Copy mail from Gmail to my server, excluding stuff I don't want.
+  gmail to my server:
+    from: imaps://imap.gmail.com
+    from-user: example
+    from-pass: secret
+
+    to: imaps://mail.example.com
+    to-user: example
+    to-pass: secret
+
+    exclude:
+      - &quot;[Gmail]/Sent Mail&quot;
+      - &quot;[Gmail]/Spam&quot;
+      - &quot;[Gmail]/Trash&quot;
+
+  # Copy mail from my INBOX to Gmail's INBOX
+  my inbox to gmail inbox:
+    all-subscribed: false
+
+    from: imaps://mail.example.com
+    from-folder: INBOX
+    from-user: example
+    from-pass: secret
+
+    to: imaps://imap.gmail.com
+    to-folder: INBOX
+    to-user: example
+    to-pass: secret
+
+This file contains three sections. The options from +default+ will be used in
+all other sections as well unless they're overridden.
+
+To specify which config section you want Larch to use, just pass its name on the
+command line (use quotes if the name contains spaces):
+
+  larch 'gmail to my server'
+
+If you specify additional command line options, they'll override options in the
+config file:
+
+  larch 'gmail to my server' --from-user anotheruser
+
+Running Larch with no command line arguments will cause the +default+ section
+to be used. With the example above, this will result in an error since the
++default+ section doesn't contain the required +from+ and +to+ options, but if
+you only need to use Larch with a single configuration, you could use the
++default+ section for everything and save yourself some typing on the command
+line.
+
 == Server Compatibility
 
 Larch should work well with any server that properly supports</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -45,7 +45,7 @@ Rake::RDocTask.new do |rd|
   rd.title    = 'Larch Documentation'
   rd.rdoc_dir = 'doc'
 
-  rd.rdoc_files.include('README.rdoc', 'lib/**/*.rb')
+  rd.rdoc_files.include('README.rdoc', 'HISTORY', 'lib/**/*.rb')
 
   rd.options &lt;&lt; '--line-numbers' &lt;&lt; '--inline-source'
 end</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -11,120 +11,97 @@ module Larch
   # Parse command-line options.
   options = Trollop.options do
     version &quot;Larch #{APP_VERSION}\n&quot; &lt;&lt; APP_COPYRIGHT
-    banner &lt;&lt;EOS
+    banner &lt;&lt;-EOS
 Larch syncs messages from one IMAP server to another. Awesomely.
 
 Usage:
+  larch [config section] [options]
   larch --from &lt;uri&gt; --to &lt;uri&gt; [options]
 
-Required:
+Server Options:
 EOS
-    opt :from, &quot;URI of the source IMAP server.&quot;, :short =&gt; '-f', :type =&gt; :string, :required =&gt; true
-    opt :to,   &quot;URI of the destination IMAP server.&quot;, :short =&gt; '-t', :type =&gt; :string, :required =&gt; true
+    opt :from,        &quot;URI of the source IMAP server.&quot;, :short =&gt; '-f', :type =&gt; :string
+    opt :from_folder, &quot;Source folder to copy from&quot;, :short =&gt; '-F', :default =&gt; Config::DEFAULT['from-folder']
+    opt :from_pass,   &quot;Source server password (default: prompt)&quot;, :short =&gt; '-p', :type =&gt; :string
+    opt :from_user,   &quot;Source server username (default: prompt)&quot;, :short =&gt; '-u', :type =&gt; :string
+    opt :to,          &quot;URI of the destination IMAP server.&quot;, :short =&gt; '-t', :type =&gt; :string
+    opt :to_folder,   &quot;Destination folder to copy to&quot;, :short =&gt; '-T', :default =&gt; Config::DEFAULT['to-folder']
+    opt :to_pass,     &quot;Destination server password (default: prompt)&quot;, :short =&gt; '-P', :type =&gt; :string
+    opt :to_user,     &quot;Destination server username (default: prompt)&quot;, :short =&gt; '-U', :type =&gt; :string
 
     text &quot;\nSync Options:&quot;
-    opt :all,              &quot;Copy all folders recursively&quot;, :short =&gt; :none
-    opt :all_subscribed,   &quot;Copy all subscribed folders recursively&quot;, :short =&gt; :none
+    opt :all,              &quot;Copy all folders recursively&quot;, :short =&gt; '-a'
+    opt :all_subscribed,   &quot;Copy all subscribed folders recursively&quot;, :short =&gt; '-s'
     opt :exclude,          &quot;List of mailbox names/patterns that shouldn't be copied&quot;, :short =&gt; :none, :type =&gt; :strings, :multi =&gt; true
     opt :exclude_file,     &quot;Filename containing mailbox names/patterns that shouldn't be copied&quot;, :short =&gt; :none, :type =&gt; :string
-    opt :from_folder,      &quot;Source folder to copy from&quot;, :short =&gt; :none, :default =&gt; 'INBOX'
-    opt :from_pass,        &quot;Source server password (default: prompt)&quot;, :short =&gt; :none, :type =&gt; :string
-    opt :from_user,        &quot;Source server username (default: prompt)&quot;, :short =&gt; :none, :type =&gt; :string
-    opt :to_folder,        &quot;Destination folder to copy to&quot;, :short =&gt; :none, :default =&gt; 'INBOX'
-    opt :to_pass,          &quot;Destination server password (default: prompt)&quot;, :short =&gt; :none, :type =&gt; :string
-    opt :to_user,          &quot;Destination server username (default: prompt)&quot;, :short =&gt; :none, :type =&gt; :string
 
     text &quot;\nGeneral Options:&quot;
-    opt :database,         &quot;Specify a non-default message database to use&quot;, :short =&gt; :none, :default =&gt; File.join('~', '.larch', 'larch.db')
+    opt :config,           &quot;Specify a non-default config file to use&quot;, :short =&gt; '-c', :default =&gt; Config::DEFAULT['config']
+    opt :database,         &quot;Specify a non-default message database to use&quot;, :short =&gt; :none, :default =&gt; Config::DEFAULT['database']
     opt :dry_run,          &quot;Don't actually make any changes&quot;, :short =&gt; '-n'
-    opt :max_retries,      &quot;Maximum number of times to retry after a recoverable error&quot;, :short =&gt; :none, :default =&gt; 3
+    opt :max_retries,      &quot;Maximum number of times to retry after a recoverable error&quot;, :short =&gt; :none, :default =&gt; Config::DEFAULT['max-retries']
     opt :no_create_folder, &quot;Don't create destination folders that don't already exist&quot;, :short =&gt; :none
     opt :ssl_certs,        &quot;Path to a trusted certificate bundle to use to verify server SSL certificates&quot;, :short =&gt; :none, :type =&gt; :string
     opt :ssl_verify,       &quot;Verify server SSL certificates&quot;, :short =&gt; :none
-    opt :verbosity,        &quot;Output verbosity: debug, info, warn, error, or fatal&quot;, :short =&gt; '-V', :default =&gt; 'info'
+    opt :verbosity,        &quot;Output verbosity: debug, info, warn, error, or fatal&quot;, :short =&gt; '-V', :default =&gt; Config::DEFAULT['verbosity']
   end
 
-  # Validate command-line options.
-  [:from, :to].each do |sym|
-    unless options[sym] =~ IMAP::REGEX_URI
-      Trollop.die sym, &quot;must be a valid IMAP URI (e.g. imap://example.com)&quot;
-    end
-  end
-
-  unless Logger::LEVELS.has_key?(options[:verbosity].to_sym)
-    Trollop.die :verbosity, &quot;must be one of: #{Logger::LEVELS.keys.join(', ')}&quot;
-  end
-
-  if options[:exclude_file_given]
-    filename = options[:exclude_file]
-
-    Trollop.die :exclude_file, &quot;: file not found: #{filename}&quot; unless File.file?(filename)
-    Trollop.die :exclude_file, &quot;: file cannot be read: #{filename}&quot; unless File.readable?(filename)
+  # Load config.
+  config = Config.new(ARGV.shift || 'default', options[:config], options)
+  
+  if options[:config_given]
+    Trollop.die :config, &quot;: file not found: #{options[:config]}&quot; unless File.exist?(options[:config])
   end
 
-  # Prevent conflicting options from being used.
-  if options[:all_given]
-    [:all_subscribed, :from_folder, :to_folder].each do |o|
-      Trollop.die :all, &quot;may not be used with --#{o.to_s.gsub('_', '-')}&quot; if options[&quot;#{o}_given&quot;.to_sym]
-    end
-  end
-
-  if options[:all_subscribed_given]
-    [:all, :from_folder, :to_folder].each do |o|
-      Trollop.die :all_subscribed, &quot;may not be used with --#{o.to_s.gsub('_', '-')}&quot; if options[&quot;#{o}_given&quot;.to_sym]
-    end
+  # Validate config.
+  begin
+    config.validate
+  rescue Config::Error =&gt; e
+    abort &quot;Config error: #{e}&quot;
   end
 
   # Create URIs.
-  uri_from = URI(options[:from])
-  uri_to   = URI(options[:to])
+  uri_from = URI(config.from)
+  uri_to   = URI(config.to)
 
-  # --all and --all-subscribed options override folders specified in URIs
-  if options[:all_given] || options[:all_subscribed_given]
+  # Use --from-folder and --to-folder unless folders were specified in the URIs.
+  uri_from.path ||= '/' + CGI.escape(config.from_folder.gsub(/^\//, ''))
+  uri_to.path   ||= '/' + CGI.escape(config.to_folder.gsub(/^\//, ''))
+
+  # --all and --all-subscribed options override folders
+  if config.all || config.all_subscribed
     uri_from.path = ''
     uri_to.path   = ''
   end
 
-  # --from-folder and --to-folder options override folders specified in URIs
-  if options[:from_folder_given] || options[:to_folder_given]
-    uri_from.path = '/' + CGI.escape(options[:from_folder].gsub(/^\//, ''))
-    uri_to.path   = '/' + CGI.escape(options[:to_folder].gsub(/^\//, ''))
-  end
-
   # Usernames and passwords specified as arguments override those in the URIs
-  uri_from.user     = CGI.escape(options[:from_user]) if options[:from_user]
-  uri_from.password = CGI.escape(options[:from_pass]) if options[:from_pass]
-  uri_to.user       = CGI.escape(options[:to_user]) if options[:to_user]
-  uri_to.password   = CGI.escape(options[:to_pass]) if options[:to_pass]
+  uri_from.user     = CGI.escape(config.from_user) if config.from_user
+  uri_from.password = CGI.escape(config.from_pass) if config.from_pass
+  uri_to.user       = CGI.escape(config.to_user) if config.to_user
+  uri_to.password   = CGI.escape(config.to_pass) if config.to_pass
 
-  # If usernames/passwords aren't specified in either URIs or args, then prompt.
+  # If usernames/passwords aren't specified in either URIs or config, then prompt.
   uri_from.user     ||= CGI.escape(ask(&quot;Source username (#{uri_from.host}): &quot;))
   uri_from.password ||= CGI.escape(ask(&quot;Source password (#{uri_from.host}): &quot;) {|q| q.echo = false })
   uri_to.user       ||= CGI.escape(ask(&quot;Destination username (#{uri_to.host}): &quot;))
   uri_to.password   ||= CGI.escape(ask(&quot;Destination password (#{uri_to.host}): &quot;) {|q| q.echo = false })
 
   # Go go go!
-  init(options[:database],
-    :exclude      =&gt; options[:exclude] ? options[:exclude].flatten : [],
-    :exclude_file =&gt; options[:exclude_file],
-    :log_level    =&gt; options[:verbosity]
-  )
-
-  Net::IMAP.debug = true if @log.level == :insane
+  init(config)
 
   imap_from = Larch::IMAP.new(uri_from,
-      :dry_run     =&gt; options[:dry_run],
-      :max_retries =&gt; options[:max_retries],
-      :ssl_certs   =&gt; options[:ssl_certs] || nil,
-      :ssl_verify  =&gt; options[:ssl_verify]
+      :dry_run     =&gt; config[:dry_run],
+      :max_retries =&gt; config[:max_retries],
+      :ssl_certs   =&gt; config[:ssl_certs] || nil,
+      :ssl_verify  =&gt; config[:ssl_verify]
   )
 
   imap_to = Larch::IMAP.new(uri_to,
-      :create_mailbox =&gt; !options[:no_create_folder] &amp;&amp; !options[:dry_run],
-      :dry_run        =&gt; options[:dry_run],
-      :max_retries    =&gt; options[:max_retries],
-      :ssl_certs      =&gt; options[:ssl_certs] || nil,
-      :ssl_verify     =&gt; options[:ssl_verify]
+      :create_mailbox =&gt; !config[:no_create_folder] &amp;&amp; !config[:dry_run],
+      :dry_run        =&gt; config[:dry_run],
+      :max_retries    =&gt; config[:max_retries],
+      :ssl_certs      =&gt; config[:ssl_certs] || nil,
+      :ssl_verify     =&gt; config[:ssl_verify]
   )
 
   unless RUBY_PLATFORM =~ /mswin|mingw|bccwin|wince|java/
@@ -136,9 +113,9 @@ EOS
     end
   end
 
-  if options[:all_given]
+  if config.all
     copy_all(imap_from, imap_to)
-  elsif options[:all_subscribed_given]
+  elsif config.all_subscribed
     copy_all(imap_from, imap_to, true)
   else
     copy_folder(imap_from, imap_to)</diff>
      <filename>bin/larch</filename>
    </modified>
    <modified>
      <diff>@@ -2,15 +2,15 @@
 
 Gem::Specification.new do |s|
   s.name = %q{larch}
-  s.version = &quot;1.0.2.2&quot;
+  s.version = &quot;1.0.2.3&quot;
 
   s.required_rubygems_version = Gem::Requirement.new(&quot;&gt;= 0&quot;) if s.respond_to? :required_rubygems_version=
   s.authors = [&quot;Ryan Grove&quot;]
-  s.date = %q{2009-08-19}
+  s.date = %q{2009-08-22}
   s.default_executable = %q{larch}
   s.email = %q{ryan@wonko.com}
   s.executables = [&quot;larch&quot;]
-  s.files = [&quot;HISTORY&quot;, &quot;LICENSE&quot;, &quot;README.rdoc&quot;, &quot;bin/larch&quot;, &quot;lib/larch/db/account.rb&quot;, &quot;lib/larch/db/mailbox.rb&quot;, &quot;lib/larch/db/message.rb&quot;, &quot;lib/larch/db/migrate/001_create_schema.rb&quot;, &quot;lib/larch/errors.rb&quot;, &quot;lib/larch/imap/mailbox.rb&quot;, &quot;lib/larch/imap.rb&quot;, &quot;lib/larch/logger.rb&quot;, &quot;lib/larch/version.rb&quot;, &quot;lib/larch.rb&quot;]
+  s.files = [&quot;HISTORY&quot;, &quot;LICENSE&quot;, &quot;README.rdoc&quot;, &quot;bin/larch&quot;, &quot;lib/larch/config.rb&quot;, &quot;lib/larch/db/account.rb&quot;, &quot;lib/larch/db/mailbox.rb&quot;, &quot;lib/larch/db/message.rb&quot;, &quot;lib/larch/db/migrate/001_create_schema.rb&quot;, &quot;lib/larch/errors.rb&quot;, &quot;lib/larch/imap/mailbox.rb&quot;, &quot;lib/larch/imap.rb&quot;, &quot;lib/larch/logger.rb&quot;, &quot;lib/larch/version.rb&quot;, &quot;lib/larch.rb&quot;]
   s.homepage = %q{http://github.com/rgrove/larch/}
   s.require_paths = [&quot;lib&quot;]
   s.required_ruby_version = Gem::Requirement.new(&quot;&gt;= 1.8.6&quot;)</diff>
      <filename>larch.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -8,10 +8,12 @@ require 'fileutils'
 require 'net/imap'
 require 'time'
 require 'uri'
+require 'yaml'
 
 require 'sequel'
 require 'sequel/extensions/migration'
 
+require 'larch/config'
 require 'larch/errors'
 require 'larch/imap'
 require 'larch/imap/mailbox'
@@ -21,21 +23,19 @@ require 'larch/version'
 module Larch
 
   class &lt;&lt; self
-    attr_reader :db, :log, :exclude
+    attr_reader :config, :db, :log, :exclude
 
     EXCLUDE_COMMENT = /#.*$/
     EXCLUDE_REGEX   = /^\s*\/(.*)\/\s*/
     GLOB_PATTERNS   = {'*' =&gt; '.*', '?' =&gt; '.'}
     LIB_DIR         = File.join(File.dirname(File.expand_path(__FILE__)), 'larch')
 
-    def init(database, config = {})
-      @config = {
-        :exclude   =&gt; [],
-        :log_level =&gt; :info
-      }.merge(config)
+    def init(config)
+      raise ArgumentError, &quot;config must be a Larch::Config instance&quot; unless config.is_a?(Config)
 
-      @log = Logger.new(@config[:log_level])
-      @db  = open_db(database)
+      @config = config
+      @log    = Logger.new(@config[:verbosity])
+      @db     = open_db(@config[:database])
 
       @exclude = @config[:exclude].map do |e|
         if e =~ EXCLUDE_REGEX
@@ -47,6 +47,8 @@ module Larch
 
       load_exclude_file(@config[:exclude_file]) if @config[:exclude_file]
 
+      Net::IMAP.debug = true if @log.level == :insane
+
       # Stats
       @copied = 0
       @failed = 0</diff>
      <filename>lib/larch.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,10 @@
 module Larch
   class Error &lt; StandardError; end
 
+  class Config
+    class Error &lt; Larch::Error; end
+  end
+
   class IMAP
     class Error &lt; Larch::Error; end
     class FatalError &lt; Error; end</diff>
      <filename>lib/larch/errors.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 module Larch
   APP_NAME      = 'Larch'
-  APP_VERSION   = '1.0.2.2'
+  APP_VERSION   = '1.0.2.3'
   APP_AUTHOR    = 'Ryan Grove'
   APP_EMAIL     = 'ryan@wonko.com'
   APP_URL       = 'http://github.com/rgrove/larch/'</diff>
      <filename>lib/larch/version.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b4fc00f0add21a4ed0f0bf35f72a79c4250aed06</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Grove</name>
    <email>ryan@wonko.com</email>
  </author>
  <url>http://github.com/rgrove/larch/commit/b51d341170ab4166019f2208898ee94bec3fd226</url>
  <id>b51d341170ab4166019f2208898ee94bec3fd226</id>
  <committed-date>2009-08-22T17:35:29-07:00</committed-date>
  <authored-date>2009-08-22T17:35:29-07:00</authored-date>
  <message>Add config file support and documentation</message>
  <tree>27ddc31ed269c3186d21a1b29125ade56a6c0ac9</tree>
  <committer>
    <name>Ryan Grove</name>
    <email>ryan@wonko.com</email>
  </committer>
</commit>
