<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,7 @@
 module GitLighthouse
   class Base
     
+    attr_reader :lh_url, :account, :projectId, :token, :email, :password
     
     def initialize(working_dir, options = {})
       @git = Git.init(working_dir, options)</diff>
      <filename>lib/git-lighthouse/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,10 +31,12 @@ module GitLighthouse
         handle_ticket_show
       when 'checkout', 'co'
         handle_ticket_checkout
-      when 'comment'
-        handle_ticket_comment
       when 'apply'
         handle_ticket_apply
+      when 'attachment'
+        handle_ticket_attachment
+      when 'comment'
+        handle_ticket_comment
       when 'recent'
         handle_ticket_recent
       else
@@ -135,16 +137,17 @@ module GitLighthouse
     
     # outputs actual patch file, include ID=XX 
     # (and optionally NUMBER=XX if more than 1)
-    def show_attach
-      setup_env
+    def handle_ticket_attachment
+      tid = ARGV[1].chomp
+      attId = ARGV[1].chomp
 
-      if tic = get_ticket(ENV['ID'])
-        doc = Hpricot(open(get_url(tic)))
+      if tic = @lh.get_ticket(tid)
+        doc = Hpricot(open(@lh.get_url(tic)))
         urls = []
         (doc/&quot;ul.attachments&quot;/:li/:ins/:h4/:a).each do |t| 
-          urls &lt;&lt; LH_URL + t['href']
+          urls &lt;&lt; @lh.lh_url + t['href']
         end      
-        idx = ((urls.size &gt; 1) &amp;&amp; (ENV['NUMBER'])) ? ENV['NUMBER'].to_i - 1 : 0
+        idx = ((urls.size &gt; 1) &amp;&amp; (attId)) ? attId.to_i - 1 : 0
         puts open(urls[idx]).read if urls[idx]
       end
     end
@@ -239,8 +242,14 @@ module GitLighthouse
     
     def parse_options! #:nodoc:      
       if args.empty?
-        warn &quot;Please specify at least one action to execute.&quot;
-        puts &quot; list state show new checkout comment tag assign &quot;
+        warn &quot;Please specify at least one action to execute:&quot;
+        puts &quot;  list - list patch tickets in lighthouse&quot;
+        puts &quot;  show (id) - show ticket detail &quot;
+        puts &quot;  attachment (ticket_id) [attachment number] - output patch to stdout&quot;
+        #puts &quot;  checkout (id) - create a new branch and apply ticket to it&quot;
+        #puts &quot;  apply (id) - apply ticket to current branch&quot;
+        #puts &quot;  push (id) - create new patch file and push to ticket&quot;
+        #puts &quot;  comment (id) - add comment to ticket&quot;
         exit
       end
 </diff>
      <filename>lib/git-lighthouse/cli.rb</filename>
    </modified>
    <modified>
      <diff>@@ -49,12 +49,19 @@ describe GitLighthouse::CLI do
       ob[0].should match(/this is a super cool ticket/)
     end
   end
+  
+  it &quot;should be able to output a patch file to stdout&quot; do
+    ARGV = ['attachment', '1']
+    ob = output_buffer do 
+      GitLighthouse::CLI.execute
+    end
+    ob[0].should match(/Subject: [PATCH] test patch/)
+  end
 
   it &quot;should show a help message&quot;
 
   it &quot;should determine the difference between a format-patch and a diff patch&quot;
 
-  it &quot;should be able to output a patch file to stdout&quot;
   
   it &quot;should apply a patch file as a new branch&quot;
 </diff>
      <filename>spec/cli_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lighthouse.rake</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>bb3958ab1f78dd12b6930431e59ec8bf884e6bf3</id>
    </parent>
  </parents>
  <author>
    <name>Scott Chacon</name>
    <email>schacon@gmail.com</email>
  </author>
  <url>http://github.com/schacon/git-lighthouse/commit/5ee25b3056b91e27f43efc8730dfa744a9cce900</url>
  <id>5ee25b3056b91e27f43efc8730dfa744a9cce900</id>
  <committed-date>2008-05-27T10:48:45-07:00</committed-date>
  <authored-date>2008-05-27T10:48:45-07:00</authored-date>
  <message>added attachment action</message>
  <tree>0ffca6a5d5c8a1c8c55ccc93773c1b6c185d23f2</tree>
  <committer>
    <name>Scott Chacon</name>
    <email>schacon@gmail.com</email>
  </committer>
</commit>
