Class: Commands::Info

Inherits:
Base
  • Object
show all
Defined in:
lib/commands/info.rb

Instance Attribute Summary

Attributes inherited from Base

#input, #options, #output

Instance Method Summary collapse

Methods inherited from Base

#get, #put, #sys, #with

Constructor Details

#initialize(*args) ⇒ Info

Returns a new instance of Info.



5
6
7
8
# File 'lib/commands/info.rb', line 5

def initialize(*args)
  @story_id = args.shift if args.first =~ /^(\d+)$/
  super(*args)
end

Instance Method Details

#run!Object



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
# File 'lib/commands/info.rb', line 10

def run!
  super

  unless story_id
    put "No story id was supplied and you aren't on a topic branch!"
    return 1
  end

  put "Story:         #{story.name}"
  put "URL:           #{story.url}"
  put "Labels:        #{story.labels.split(',').join(', ')}" if story.labels
  put "State:         #{story.accepted_at ? 'accepted' : 'not accepted'}"
  
  colwidth = 74
  
  put "\nDescription:\n"
  put wrap_text("#{story.description}\n", colwidth).gsub(/^/, '  ').chomp

  if options[:comments]
    put "\nComments:\n"
    story.notes.all.each do |note|
      @output.printf "  %-37s%37s\n\n", note.author, note.noted_at.strftime("%b %e, %Y %k:%M%p")
      put wrap_text(note.text, colwidth - 2).gsub(/^/, '    ')
    end
  end
  
  return 0
end