Module: LighthouseCLI::Commands

Included in:
Parser
Defined in:
lib/lighthouse_cli/commands.rb

Instance Method Summary collapse

Instance Method Details

#add(title, tags = []) ⇒ Object



3
4
5
6
# File 'lib/lighthouse_cli/commands.rb', line 3

def add(title, tags = [])
  create_ticket(title, tags)
  puts "Ticket added."
end

#helpObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/lighthouse_cli/commands.rb', line 65

def help
  puts <<-TEXT
  Available commands:
  help
Show this text.

  list [milestone_name]
List all assigned tickets from next upcoming milestone (by default). Otherwise, list all tickets in all milestones matching milestone name.

  ms [all]
List future milestones (by default). List all milestones when option "all" provided.

  show 50
Show details for ticket with given id.

  add "Ticket name" "tag1 tag2"
Add ticket for yourself into current milestone with (optional) tags and without any body.

  resolve 50
Mark ticket 50 resolved.

  open 50
Mark ticket 50 new.
  TEXT
end

#list(which = "next") ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lighthouse_cli/commands.rb', line 8

def list(which = "next")
  case which
  when 'next'
    puts "Milestone: #{fetch_next_milestone.title}"
    tickets = fetch_tickets("responsible:me milestone:#{fetch_next_milestone.title} state:open sort:priority")
    display_tickets tickets
  else
    milestones = fetch_milestones_by_title(which)
    milestones.each do |ms|
      puts "Milestone: #{ms.title}"
      tickets = fetch_tickets("responsible:me milestone:#{ms.title} state:open sort:priority")
      display_tickets tickets
      puts "\n"
      sleep 1
    end
  end
end

#ms(which = "future") ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/lighthouse_cli/commands.rb', line 54

def ms(which = "future")
  milestones = case which
  when 'all'
    fetch_all_milestones
  when 'future'
    fetch_future_milestones
  end
  
  display_milestones milestones 
end

#open(id) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/lighthouse_cli/commands.rb', line 36

def open(id)
  t = fetch_ticket(id)
  t.state = 'new'
  if t.save
    puts "Opened: \"#{t.title}\""
  else
    puts "Failed trying to open ticket."
  end
end

#resolve(id) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/lighthouse_cli/commands.rb', line 26

def resolve(id)
  t = fetch_ticket(id)
  t.state = 'resolved'
  if t.save
    puts "Resolved: \"#{t.title}\""
  else
    puts "Failed trying to resolve ticket."
  end
end

#show(id) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/lighthouse_cli/commands.rb', line 46

def show(id)
  ticket = fetch_ticket(id)
  puts "  Ticket ##{id} (#{ticket.state})"
  puts "  #{ticket.title}"
  puts "  #{ticket.body}" unless ticket.body.blank?
  puts "  #{ticket.tags.join(', ')}" unless ticket.tags.blank? 
end