Class: Ptb::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/ptb/cli.rb

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



3
4
5
6
7
8
9
# File 'lib/ptb/cli.rb', line 3

def initialize(*)
  super

  Signal.trap("SIGINT") do
    exit!
  end
end

Instance Method Details

#branchObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ptb/cli.rb', line 14

def branch
  branches=`git branch`

  branches.each_line do |line|
    branch = line[2..-2]
    if branch =~ /^[0-9]+$/
      if story = project.stories.find(branch)
        say "#{line.rstrip} [#{story.current_state}] #{story.name} (#{story.url})"
      else
        say line.rstrip
      end
    else
      say line.rstrip
    end
  end
end

#messageObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ptb/cli.rb', line 33

def message
  branch = `git symbolic-ref --short HEAD`.strip
  if branch =~ /^[0-9]+$/
    if story = project.stories.find(branch)
      puts <<-EOS
[##{branch}] 

#{word_wrap(story.name, :line_width => 72)}
#{story.url}
      EOS
    end
  end
end