<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/gitjour/.application.rb.swp</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,41 +1,9 @@
 #!/usr/bin/env ruby
 require 'rubygems'
-require 'cooloptions'
 require 'gitjour'
 
-COMMANDS = {
-  'list' =&gt; 'Lists available repositories.',
-  'clone' =&gt; 'Clone a gitjour served repository.',
-  'serve' =&gt; 'Serve up the current directory via gitjour.'
-}
-
-options = CoolOptions.parse!(&quot;[options] command [name]&quot;) do |o|
-  o.desc 'Serve up and use git repositories via Bonjour/DNSSD.'
-  o.desc &quot;\n&quot;
-  
-  o.desc &quot;Commands:&quot;
-  COMMANDS.each do |c, help|
-    o.desc &quot;  #{c.ljust(5)}  #{help}&quot;
-  end
-  
-  o.desc &quot;\n&quot;
-  
-  o.desc &quot;Options:&quot;
-  o.on '(P)port PORT', &quot;Pass to serve to serve on a different port.&quot;, 9418
-  o.on 'path PATH',    &quot;Path to serve.&quot;
-  o.on 'verbose',      &quot;Verbose output.&quot;, false
-  
-  o.after do |result|
-    (result.command = ARGV.shift) || o.error(&quot;Command is required.&quot;)
-    o.error(&quot;Unknown command.&quot;) if !COMMANDS.keys.include?(result.command)
-    result.name = ARGV.shift
-    o.error(&quot;Name is required.&quot;) if result.command == &quot;clone&quot; &amp;&amp; !result.name
-    result.port = result.port.to_i
-  end
-end
-
 trap &quot;INT&quot; do
   exit!
 end
 
-Gitjour::Application.run(options)
+Gitjour::Application.run(*ARGV)</diff>
      <filename>bin/gitjour</filename>
    </modified>
    <modified>
      <diff>@@ -56,7 +56,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
   p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
   p.test_globs = [&quot;test/**/test_*.rb&quot;]
   p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']  #An array of file patterns to delete on clean.
-  p.extra_deps =  ['dnssd', 'cooloptions']
+  p.extra_deps =  ['dnssd']
   # == Optional
   p.changes = p.paragraphs_of(&quot;History.txt&quot;, 0..1).join(&quot;\n\n&quot;)
   #p.extra_deps = []     # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '&gt;= 1.3.1'] ]
@@ -68,4 +68,4 @@ end
 CHANGES = hoe.paragraphs_of('History.txt', 0..1).join(&quot;\\n\\n&quot;)
 PATH    = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : &quot;#{RUBYFORGE_PROJECT}/#{GEM_NAME}&quot;
 hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
-hoe.rsync_args = '-av --delete --ignore-errors'
\ No newline at end of file
+hoe.rsync_args = '-av --delete --ignore-errors'</diff>
      <filename>config/hoe.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
 require 'rubygems'
 require 'dnssd'
 require 'set'
+require 'gitjour/version'
+
 Thread.abort_on_exception = true
 
 module Gitjour
@@ -9,17 +11,16 @@ module Gitjour
   class Application
 
     class &lt;&lt; self
-      def run(options)
-        @@verbose = options.verbose
-        case options.command
+      def run(*args)
+        case args.shift
           when &quot;list&quot;
             list
           when &quot;clone&quot;
-            clone(options.name)
+            clone(*args)
           when &quot;serve&quot;
-            serve(options.name, options.path, options.port)
+            serve(*args)
           when &quot;remote&quot;
-            remote(options.name)
+            remote(*args)
           else
             help
         end
@@ -28,35 +29,73 @@ module Gitjour
       private
 			def list
 				service_list.each do |service|
-          puts &quot;=== #{service.name} on #{service.host} ===&quot;
+          puts &quot;=== #{service.name} on #{service.host}:#{service.port} ===&quot;
           puts &quot;  gitjour clone #{service.name}&quot;
-          puts &quot;  #{service.description}&quot; if service.description &amp;&amp; service.description != '' &amp;&amp; service.description !~ /^Unnamed repository/
+          if service.description != '' &amp;&amp; service.description !~ /^Unnamed repository/
+            puts &quot;  #{service.description}&quot;
+          end
           puts
         end
 			end
 
-      def get_host_and_share(repository_name)
-        name_of_share = repository_name || fail(&quot;You have to pass in a name&quot;)
-        host = service_list(name_of_share).detect{|service| service.name == name_of_share}.host rescue exit_with!(&quot;Couldn't find #{name_of_share}&quot;)
-        system(&quot;git clone git://#{host}/ #{name_of_share}/&quot;)  
-        [host, name_of_share]
-      end
+      def clone(repository_name, *rest)
+        dir = rest.shift || repository_name
+        if File.exists?(dir)
+          exit_with! &quot;ERROR: Clone directory '#{dir}' already exists.&quot;
+        end
 
-      def clone(name)
-        service = service_list(name).detect{|service| service.name == name} rescue exit_with!(&quot;Couldn't find #{name}&quot;)
-        cl(&quot;git clone git://#{service.host}:#{service.port}/ #{name}/&quot;)
+        puts &quot;Cloning '#{repository_name}' into directory '#{dir}'...&quot;
+
+        service = locate_repo repository_name
+        puts &quot;Connecting to #{service.host}:#{service.port}&quot;
+
+        system &quot;git clone git://#{service.host}:#{service.port}/ #{dir}/&quot;
       end
 
-      def remote(repository_name,*rest)
-        host, name_of_share = get_host_and_share(repository_name)
-        system(&quot;git remote add #{name_of_share} git://#{host}/&quot;)
+      def remote(repository_name, *rest)
+        dir = rest.shift || repository_name
+        service = locate_repo repository_name
+        system &quot;git remote add #{dir} git://#{service.host}:#{service.port}/&quot;
       end
 
-      def serve(path, port)
-        path ||= Dir.pwd
+      def serve(path=Dir.pwd, *rest)
         path = File.expand_path(path)
-        File.exists?(&quot;#{path}/.git&quot;) ? announce_repo(path, port) : Dir[&quot;#{path}/*&quot;].each_with_index{|dir,i| announce_repo(dir, port+i) if File.directory?(dir)}
-        cl(&quot;git-daemon --verbose --export-all --port=#{port} --base-path=#{path} --base-path-relaxed&quot;)
+        name = rest.shift || File.basename(path)
+        port = rest.shift || 9418
+        
+        if File.exists?(&quot;#{path}/.git&quot;)
+          announce_repo(path, name, port.to_i)
+        else
+          Dir[&quot;#{path}/*&quot;].each do |dir|
+            if File.directory?(dir)
+              name = File.basename(dir)
+              announce_repo(dir, name, 9418)
+            end
+          end
+        end
+
+        `git-daemon --verbose --export-all --port=#{port} --base-path=#{path} --base-path-relaxed`
+      end
+
+      def help
+        puts &quot;Gitjour #{Gitjour::VERSION::STRING}&quot;
+        puts &quot;Serve up and use git repositories via Bonjour/DNSSD.&quot;
+        puts &quot;\nUsage: gitjour &lt;command&gt; [args]&quot;
+        puts
+        puts &quot;  list&quot;
+        puts &quot;      Lists available repositories.&quot;
+        puts
+        puts &quot;  clone &lt;project&gt; [&lt;directory&gt;]&quot;
+        puts &quot;      Clone a gitjour served repository.&quot;
+        puts
+        puts &quot;  serve &lt;path_to_project&gt; [&lt;name_of_project&gt;] [&lt;port&gt;] or&quot;
+        puts &quot;        &lt;path_to_projects&gt;&quot;
+        puts &quot;      Serve up the current directory or projects via gitjour.&quot;
+        puts
+        puts &quot;  remote &lt;project&gt; [&lt;name&gt;]&quot;
+        puts &quot;      Add a Bonjour remote into your current repository.&quot;
+        puts &quot;      Optionally pass name to not use pwd.&quot;
+        puts
       end
 
       def exit_with!(message)
@@ -64,43 +103,61 @@ module Gitjour
         exit!
       end
 
-      def service_list(looking_for = nil)
-        wait_seconds = 5
+      class Done &lt; RuntimeError; end
 
-        service_list = Set.new
-        waiting_thread = Thread.new { sleep wait_seconds }
+      def discover(timeout=5)
+        waiting_thread = Thread.current
 
-        service = DNSSD.browse &quot;_git._tcp&quot; do |reply|
+        dns = DNSSD.browse &quot;_git._tcp&quot; do |reply|
           DNSSD.resolve reply.name, reply.type, reply.domain do |resolve_reply|
-            service_list &lt;&lt; GitService.new(reply.name, resolve_reply.target, resolve_reply.port, resolve_reply.text_record['description'])
-            if looking_for &amp;&amp; reply.name == looking_for
-              waiting_thread.kill
+            service = GitService.new(reply.name,
+                                     resolve_reply.target,
+                                     resolve_reply.port,
+                                     resolve_reply.text_record['description'].to_s)
+            begin
+              yield service
+            rescue Done
+              waiting_thread.run
             end
           end
         end
-        puts &quot;Gathering for up to #{wait_seconds} seconds...&quot;
-        waiting_thread.join
-        service.stop
-        service_list
+
+        puts &quot;Gathering for up to #{timeout} seconds...&quot;
+        sleep timeout
+        dns.stop
       end
 
-      def announce_repo(name, path, port)
-        return unless File.exists?(&quot;#{path}/.git&quot;)
-        name = share_name || File.basename(path)
-        tr = DNSSD::TextRecord.new
-        tr['description'] = File.read(&quot;.git/description&quot;) rescue &quot;a git project&quot;
-        DNSSD.register(name, &quot;_git._tcp&quot;, 'local', port, tr.encode) do |register_reply| 
-          puts &quot;Registered #{name}.  Starting service.&quot;
+      def locate_repo(name)
+        found = nil
+
+        discover do |obj|
+          if obj.name == name
+            found = obj
+            raise Done
+          end
         end
+
+        return found
+      end
+
+      def service_list
+        list = Set.new
+        discover { |obj| list &lt;&lt; obj }
+
+        return list
       end
-      
-      def cl(command)
-        output = `#{command}`
-        if @@verbose
-          puts command
-          puts output
+
+      def announce_repo(path, name, port)
+        return unless File.exists?(&quot;#{path}/.git&quot;)
+
+        tr = DNSSD::TextRecord.new
+        tr['description'] = File.read(&quot;#{path}/.git/description&quot;) rescue &quot;a git project&quot;
+
+        DNSSD.register(name, &quot;_git._tcp&quot;, 'local', port, tr.encode) do |rr|
+          puts &quot;Registered #{name} on port #{port}. Starting service.&quot;
         end
       end
+
     end
   end
 end</diff>
      <filename>lib/gitjour/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 module Gitjour #:nodoc:
   module VERSION #:nodoc:
     MAJOR = 6
-    MINOR = 1
+    MINOR = 2
     TINY  = 0
 
     STRING = [MAJOR, MINOR, TINY].join('.')</diff>
      <filename>lib/gitjour/version.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>aeba310d792840faeb27bdcac6a4ef446636ac8f</id>
    </parent>
  </parents>
  <author>
    <name>Evan Phoenix</name>
    <email>evan@fallingsnow.net</email>
  </author>
  <url>http://github.com/lachlanhardy/gitjour/commit/952d7594a305c2bbd119b49f0a792dc98d7a2c63</url>
  <id>952d7594a305c2bbd119b49f0a792dc98d7a2c63</id>
  <committed-date>2008-05-31T23:33:17-07:00</committed-date>
  <authored-date>2008-05-31T22:59:08-07:00</authored-date>
  <message>Refactor, reformat, reunfuck, 6.2.0 is in the bag!

Remove cooloptions, it's not necessary.</message>
  <tree>2cb084b6d9b0dfad18a0cab02cb7aca74560274a</tree>
  <committer>
    <name>Evan Phoenix</name>
    <email>evan@fallingsnow.net</email>
  </committer>
</commit>
