<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>help/grab.rdoc</filename>
    </added>
    <added>
      <filename>help/map.rdoc</filename>
    </added>
    <added>
      <filename>help/update.rdoc</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,7 @@
 bin/brigit
+help/grab.rdoc
+help/map.rdoc
+help/update.rdoc
 lib/brigit/cli.rb
 lib/brigit/commands/command.rb
 lib/brigit/commands/grab_command.rb</diff>
      <filename>Manifest</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,5 @@
 
 require File.dirname(__FILE__) &lt;&lt; &quot;/../lib/brigit&quot;
 
-Brigit::CLI.new.parse(*ARGV) do |command|
-  command.execute!
-end
+Brigit::CLI.new.parse(*ARGV).run
   
\ No newline at end of file</diff>
      <filename>bin/brigit</filename>
    </modified>
    <modified>
      <diff>@@ -5,60 +5,24 @@ module Brigit
   class CLI
     
     def parse(*args)
-      self.class.parser.parse!(args)
-      if (args.first &amp;&amp; command = Command[args.shift])
-        yield command.new(self.class.options, *args)
+      if (command = Command[args.shift])
+        command.new(*args)
       else
-        abort &quot;No command given.\n#{self.class.parser}&quot;
+        abort &quot;No command given.\n\n#{self.class.usage}&quot;
       end
     end
-        
-    def self.usage
-      parser.to_s
-    end
-    
-    #######
-    private
-    #######
     
-    def self.options
-      @options ||= OpenStruct.new
+    def self.banner
+      %{Brigit (v#{Version::STRING}) Submodule utilities for Git}
     end
-    
-    def self.parser
-      
-      command_list = Command.list.map { |command| &quot;  * #{command.name}: #{command.help}&quot; }.join(&quot;\n&quot;)
-      
-      options.inventory = {}
-      
-      @parser ||= OptionParser.new do |opts|
-        
-        opts.banner = %(Brigit (v#{Version::STRING}) Submodule utilities for Git\nUSAGE: brigit COMMAND [OPTIONS])
-
-        opts.separator &quot;COMMANDS:\n#{command_list}\n&quot;
         
-        opts.separator &quot;OPTIONS:\n&quot;
-
-        Inventory.list.each do |inventory|
-          opts.on(&quot;-#{inventory.name[0,1]}&quot;, &quot;--#{inventory.name} PATH&quot;, &quot;Location of #{inventory.name} (`grab' only)&quot;) do |path|
-            options.inventory[inventory] = path
-          end
-        end
-        
-        opts.on('-o', '--open', &quot;Open with Preview.app  (`map' only, requires OSX &amp; `dot' in PATH)&quot;) do
-          options.open = true
-        end
-        
-        opts.on('-v', '--version', &quot;Show version&quot;) do
-          STDERR.puts &quot;Brigit v#{Version::STRING}&quot;
-          exit
-        end
-        
-        opts.on_tail('-h', '--help', 'Show this message') do
-          abort opts.to_s
-        end
-        
-      end
+    def self.usage
+      lines = [
+        banner,
+        %{COMMANDS: (`COMMAND --help' for documentation)},
+        *Command.list.map { |cmd| &quot;  #{cmd.name}&quot; }.sort
+      ]
+      lines.join &quot;\n&quot;
     end
     
   end</diff>
      <filename>lib/brigit/cli.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,23 +7,43 @@ module Brigit
     include Listable
     include Fallible
     
-    class &lt;&lt; self
-      attr_accessor :help
+    def self.help
+      @help ||= begin
+        help_file = File.dirname(__FILE__) &lt;&lt; &quot;/../../../help/#{name}.rdoc&quot;
+        if File.file?(help_file)
+          File.read(help_file) 
+        else
+          &quot;Sorry, there is no documentation for this command.&quot;
+        end
+      end
     end
     
-    attr_reader :options, :args
-    def initialize(options, *args)
-      @options = options
+    attr_reader :args
+    def initialize(*args)
       @args = args
     end
     
-    def execute!
-      raise ArgumentError, &quot;Must be in Git repository&quot; unless repo?
+    def run
+      yield parser if block_given?
+      parser.parse!(args)
     end
     
     #######
     private
     #######
+    
+    def check_repo!
+      raise ArgumentError, &quot;Must be in Git repository&quot; unless repo?
+    end
+    
+    def parser
+      @parser ||= OptionParser.new do |opts|
+        opts.banner = CLI.banner + &quot;\n---\n= Help on the `#{self.class.name}' command\n\n&quot; + self.class.help + &quot;\n\n== Options\n&quot;
+        opts.on_tail('-h', '--help', 'Show this message') do
+          abort opts.to_s
+        end
+      end
+    end
 
     def repo?
       File.directory?(File.join(Dir.pwd, '.git'))</diff>
      <filename>lib/brigit/commands/command.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,10 +5,8 @@ module Brigit
   
   class GrabCommand &lt; Command
     
-    self.help = &quot;Grab repos matching optional pattern from a gitosis-admin config&quot;
-    
-    def execute!
-      validate!
+    def run
+      super
       matching_repositories.each do |name, location|
         if File.exists?(name)
           STDERR.puts &quot;#{name}: Already exists, skipping...&quot;
@@ -17,7 +15,7 @@ module Brigit
           system &quot;git clone '#{location}' '#{name}'&quot;
           STDERR.puts &quot;#{name}: Updating submodules ...&quot;
           Dir.chdir name do
-            updater.execute!
+            UpdateCommand.new.run
           end
         end
       end
@@ -27,22 +25,12 @@ module Brigit
     private
     #######
     
-    def updater
-      @updater ||= UpdateCommand.new(options)
-    end
-
-    def validate!
-      if options.inventory.empty?
-        list = Inventory.listing { |name| &quot;--#{name}&quot; }
-        fail &quot;Can't find list of repositories; need to set #{list}&quot;
-      end            
+    def inventory
+      @inventory ||= GitosisInventory.new(args.shift)
     end
     
     def all_repositories
-      options.inventory.inject({}) do |all, (klass, path)|
-        source = klass.new(path)
-        all.merge(source.repositories)
-      end
+      inventory.repositories
     end
     
     def matching_repositories</diff>
      <filename>lib/brigit/commands/grab_command.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,10 +5,13 @@ module Brigit
   
   class MapCommand &lt; Command
     
-    self.help = &quot;Graphs of submodules in this repository&quot;
-    
-    def execute!
-      super
+    def run
+      open = false
+      super do |parser|
+        parser.on('-o', '--open', &quot;Open as PNG in Preview.app (OSX only, requires `dot')&quot;) do
+          open = true
+        end
+      end
       text =  %|digraph G {\n|
       # TODO: Allow customization
       text &lt;&lt; %|ranksep=.75; size = &quot;12,12&quot;;\n|
@@ -21,7 +24,7 @@ module Brigit
         end
       end
       text &lt;&lt; %|}\n|
-      if options.open
+      if open
         IO.popen(&quot;dot -Tpng | open -f -a /Applications/Preview.app&quot;, 'w') do |file|
           file.write text
         end
@@ -36,18 +39,18 @@ module Brigit
     
     def origin_at(path)
       filename = File.join(path, '.git/config')
-      result = parser.parse(File.readlines(filename))
+      result = config_parser.parse(File.readlines(filename))
       result['remote &quot;origin&quot;']['url']
     end
     
     def submodules_at(path)
       filename = File.join(path, '.gitmodules')
-      result = parser.parse(File.readlines(filename))
+      result = config_parser.parse(File.readlines(filename))
       result.values
     end
 
-    def parser
-      @parser ||= ConfigParser.new
+    def config_parser
+      @config_parser ||= ConfigParser.new
     end
       
   end</diff>
      <filename>lib/brigit/commands/map_command.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,10 +4,8 @@ require 'find'
 module Brigit
   
   class UpdateCommand &lt; Command
-    
-    self.help = &quot;Update all submodules in the repo, recursively&quot;
-    
-    def execute!
+        
+    def run
       super
       Brigit.at_dot_gitmodules do |path|
         system &quot;git submodule init&quot;</diff>
      <filename>lib/brigit/commands/update_command.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f776ef88c1bfc2e8e9b77af174373b4ed3cbc56d</id>
    </parent>
  </parents>
  <author>
    <name>Bruce Williams</name>
    <email>bruce@codefluency.com</email>
  </author>
  <url>http://github.com/fiveruns/brigit/commit/82c86fd5ee6534ef8b8e04a720174e36fe59b4d7</url>
  <id>82c86fd5ee6534ef8b8e04a720174e36fe59b4d7</id>
  <committed-date>2008-07-09T07:53:27-07:00</committed-date>
  <authored-date>2008-07-09T07:53:27-07:00</authored-date>
  <message>Restucture command parsing to use Git-like format, at Adam's suggestion:
  brigit COMMAND [OPTIONS]
  For help:
    brigit COMMAND --help
* Expand command documentation</message>
  <tree>4a7f2095c12b97ca1af4de51c1fac657fc38510e</tree>
  <committer>
    <name>Bruce Williams</name>
    <email>bruce@codefluency.com</email>
  </committer>
</commit>
