Module: TicGitNG::Command::List

Defined in:
lib/ticgit-ng/command/list.rb

Overview

List tickets

Instance Method Summary collapse

Instance Method Details

#executeObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ticgit-ng/command/list.rb', line 45

def execute
  options.saved = args[0] if args[0]

  if tickets = tic.ticket_list(options.to_hash)
    counter = 0
    cols = [80, window_cols].max

    puts
    puts [' ', just('#', 4, 'r'),
      just('TicId', 6),
      just('Title', cols - 56),
      just('State', 5),
      just('Date', 5),
      just('Assgn', 8),
      just('Tags', 20) ].join(" ")

    puts "-" * cols

    tickets.each do |t|
      counter += 1
      tic.current_ticket == t.ticket_name ? add = '*' : add = ' '
      puts [add, just(counter, 4, 'r'),
        t.ticket_id[0,6],
        just(t.title, cols - 56),
        just(t.state, 5),
        t.opened.strftime("%m/%d"),
        just(t.assigned_name, 8),
        just(t.tags.join(','), 20) ].join(" ")
    end
    puts
  end

end

#parser(o) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ticgit-ng/command/list.rb', line 5

def parser(o)
  o.banner = "Usage: ti list [options]"
  o.on_head(
    "-o ORDER", "--order ORDER",
    "Field to order by - one of : assigned,state,date,title [.desc for reverse order]"){|v|
    options.order = v
  }

  o.on_head(
    "-t TAG[,TAG]", "--tags TAG[,TAG]", Array,
    "List only tickets with specific tag(s)",
    "Prefix the tag with '-' to negate"){|v|
    options.tags ||= Set.new
    options.tags.merge v
  }

  o.on_head(
    "-s STATE[,STATE]", "--states STATE[,STATE]", Array,
    "List only tickets in a specific state(s)",
    "Prefix the state with '-' to negate"){|v|
    options.states ||= Set.new
    options.states.merge v
  }

  o.on_head(
    "-a ASSIGNED", "--assigned ASSIGNED",
    "List only tickets assigned to someone"){|v|
    options.assigned = v
  }

  o.on_head("-S SAVENAME", "--saveas SAVENAME",
               "Save this list as a saved name"){|v|
    options.save = v
  }

  o.on_head("-l", "--list", "Show the saved queries"){|v|
    options.list = true
  }
end