Skip to content

Commit

Permalink
Add --no-labels option to ghi-list
Browse files Browse the repository at this point in the history
There have been a few requests for an option to prevent printing labels
when listing issues. If the list of issues involves a lot of labels, it
leads to truncation of issue titles. To make it easier to visually parse
lists like this, I've added a `--no-labels` option to `ghi-list` to
skip printing labels in the pager. Closes stephencelis#259.

Signed-off-by: David Celis <me@davidcel.is>
  • Loading branch information
davidcelis committed Apr 8, 2016
1 parent 40327ab commit 5088b5d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
12 changes: 8 additions & 4 deletions ghi
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ module GHI
(i['repo'].to_s.rjust(rmax) if i['repo']),
format_number(n.to_s.rjust(nmax)),
truncate(title, l),
format_labels(labels),
(format_labels(labels) unless assigns[:dont_print_labels]),
(fg(:green) { m['title'] } if m),
(fg('aaaaaa') { c } unless c == 0),
(fg('aaaaaa') { '↑' } if p),
Expand Down Expand Up @@ -953,8 +953,8 @@ EOF
def format_comment_editor issue, comment = nil
message = ERB.new(<<EOF).result binding
Leave a comment. Trailing lines starting with '#' (like these) will be ignored,
and empty messages will not be submitted. Comments are formatted with GitHub
Leave a comment. Trailing lines starting with '#' (like these) will be ignored,
and empty messages will not be submitted. Comments are formatted with GitHub
Flavored Markdown (GFM):
http://github.github.com/github-flavored-markdown
Expand Down Expand Up @@ -2386,7 +2386,6 @@ module GHI
attr_accessor :pull_requests_only

def options

OptionParser.new do |opts|
opts.banner = 'usage: ghi list [options]'
opts.separator ''
Expand All @@ -2410,6 +2409,11 @@ module GHI
) do |labels|
(assigns[:exclude_labels] ||= []).concat labels
end
opts.on(
'--no-labels', 'do not print labels'
) do
assigns[:dont_print_labels] = true
end
opts.on(
'-S', '--sort <by>', %w(created updated comments),
{'c'=>'created','u'=>'updated','m'=>'comments'},
Expand Down
5 changes: 5 additions & 0 deletions lib/ghi/commands/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def options
) do |labels|
(assigns[:exclude_labels] ||= []).concat labels
end
opts.on(
'--no-labels', 'do not print labels'
) do
assigns[:dont_print_labels] = true
end
opts.on(
'-S', '--sort <by>', %w(created updated comments),
{'c'=>'created','u'=>'updated','m'=>'comments'},
Expand Down
6 changes: 3 additions & 3 deletions lib/ghi/formatting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def format_issues issues, include_repo
(i['repo'].to_s.rjust(rmax) if i['repo']),
format_number(n.to_s.rjust(nmax)),
truncate(title, l),
format_labels(labels),
(format_labels(labels) unless assigns[:dont_print_labels]),
(fg(:green) { m['title'] } if m),
(fg('aaaaaa') { c } unless c == 0),
(fg('aaaaaa') { '↑' } if p),
Expand Down Expand Up @@ -413,8 +413,8 @@ def format_milestone_editor milestone = nil
def format_comment_editor issue, comment = nil
message = ERB.new(<<EOF).result binding
Leave a comment. Trailing lines starting with '#' (like these) will be ignored,
and empty messages will not be submitted. Comments are formatted with GitHub
Leave a comment. Trailing lines starting with '#' (like these) will be ignored,
and empty messages will not be submitted. Comments are formatted with GitHub
Flavored Markdown (GFM):
http://github.github.com/github-flavored-markdown
Expand Down

0 comments on commit 5088b5d

Please sign in to comment.