Class: Toolshed::Commands::CreateTicketComment
  
  
  
  
  
    - Inherits:
 
    - 
      Base
      
        
          - Object
 
          
            - Base
 
          
            - Toolshed::Commands::CreateTicketComment
 
          
        
        show all
      
     
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/toolshed/commands/create_ticket_comment.rb
 
  
  
 
  
    
      Class Method Summary
      collapse
    
    
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from Base
  parse, #read_user_input, #read_user_input_body, #read_user_input_password, #read_user_input_title, #use_project_id, #use_ticket_tracker_by_type, #use_ticket_tracker_project_id, #use_ticket_tracker_project_name
  Constructor Details
  
    
  
  
    
Returns a new instance of CreateTicketComment.
   
 
  
  
    
      
8
9
10 
     | 
    
      # File 'lib/toolshed/commands/create_ticket_comment.rb', line 8
def initialize(options={})
  super(options)
end
     | 
  
 
  
 
  
    Class Method Details
    
      
  
  
    .cli_options  ⇒ Object 
  
  
  
  
    
      
12
13
14
15
16
17
18
19
20
21 
     | 
    
      # File 'lib/toolshed/commands/create_ticket_comment.rb', line 12
def self.cli_options
  {
    banner: 'Usage: create_ticket_comment [options]',
    options: {
      use_defaults: {
        short_on: '-d'
      }
    }
  }
end
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #branch  ⇒ Object 
  
  
  
  
    
      
23
24
25 
     | 
    
      # File 'lib/toolshed/commands/create_ticket_comment.rb', line 23
def branch
  @branch ||= Toolshed::Git::Branch.new
end
 
     | 
  
 
    
      
  
  
    #execute(args, options = {})  ⇒ Object 
  
  
  
  
    
      
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 
     | 
    
      # File 'lib/toolshed/commands/create_ticket_comment.rb', line 27
def execute(args, options = {})
  ticket_tracker_class =  Object.const_get("Toolshed::TicketTracking::#{Toolshed::Client.ticket_tracking_tool.camel_case}")
  options = use_ticket_tracker_project_id(options)
  options = use_ticket_tracker_project_name(options)
  default_ticket_id = Toolshed::TicketTracking::story_id_from_branch_name(branch.name)
  ticket_id = read_user_input("Ticket ID (Default: #{default_ticket_id}):", options.merge!({ default: default_ticket_id }))
  options.merge!({ ticket_id: ticket_id })
  ticket_tracker = ticket_tracker_class.create_instance(options)
  puts "Using Project: #{ticket_tracker_project_id}" if use_project_id
  puts "Using Ticket: #{ticket_id}"
  puts "Note? "
  note_text = $stdin.gets.chomp.strip
  begin
    result = ticket_tracker.add_note(note_text)
    if (result)
      puts "Comment has been added to ticket"
    else
      puts "Unable to add comment #{result.inspect}"
    end
  rescue => e
    puts e.message
    exit
  end
end
     |