Class: PivotalShell::Commands::Story

Inherits:
PivotalShell::Command show all
Defined in:
lib/pivotal_shell/commands/story.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Story

Returns a new instance of Story.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pivotal_shell/commands/story.rb', line 6

def initialize(options)
  opts = OptionParser.new do |opts|
    opts.banner = "Show information on a Pivotal story\nUsage: pivotal story STORY_ID [options]\n\n"
    
    opts.on_tail('--help', 'Show this help') do
      puts opts
      exit
    end
  end
  opts.parse!(options)
  if options.empty? || options.length>1
    puts opts
    exit
  else
    @story_id = options.first
  end
end

Instance Method Details

#executeObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pivotal_shell/commands/story.rb', line 24

def execute
  @story = PivotalShell::Cache::Story.find(@story_id)
  if @story.nil?
    puts 'Story not found'
  else
    puts ["[#{@story.id}] - #{@story.name}",
      
          "State: #{@story.current_state}",
          "Owner: #{@story.owned_by}",
          "Creator: #{@story.requested_by}",
          "URL: #{@story.url}",
          "",
          "#{@story.description.strip}",
          "",
          ""].join("\n")
  end
end